djeuscan: move problem to another page, use an icon, restrict to registered

We may move it back to the package page later.

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
Corentin Chary 2012-07-25 16:52:10 +02:00
parent 112313ab7f
commit a12e2c42ea
7 changed files with 239 additions and 188 deletions

View File

@ -1,3 +1,5 @@
import json
from django.db import models
from django.core.validators import RegexValidator, validate_email, URLValidator
from django.core.exceptions import ValidationError
@ -215,6 +217,14 @@ class EuscanResult(models.Model):
self.full_clean()
super(EuscanResult, self).save(*args, **kwargs)
def messages(self):
result = json.loads(self.result)
if result and self.package.cp() in result:
return result[self.package.cp()]['messages']
else:
return ""
def __unicode__(self):
return '[%s] %s/%s' % (
self.datetime, self.package.category, self.package.name

View File

@ -0,0 +1,122 @@
{% load djeuscan_helpers %}
{% load url from future %}
<dl>
{% if package.description %}
<dt>Description</dt>
<dd>{{ package.description }}</dd>
{% endif %}
{% if package.homepage %}
<dt>Homepage</dt>
<dd>
{% for homepage in package.homepages %}
<a href="{{ homepage }}">{{ homepage }}</a><br />
{% endfor %}
</dd>
{% endif %}
{% if package.herds.all %}
<dt>Herds</dt>
<dd>
{% for herd in package.herds.all %}
<a href="{% url "herd" herd.herd %}">
{{ herd.herd }}
</a>
&lt;{{ herd.email }}&gt;
{% endfor %}
</dd>
{% endif %}
{% if package.maintainers.all %}
<dt>Maintainers</dt>
<dd>
{% for maintainer in package.maintainers.all %}
{% if maintainer.name != maintainer.email %}
<a href="{% url "maintainer" maintainer.id %}">
{{ maintainer.name }}
</a>
&lt;{{ maintainer.email }}&gt;
{% else %}
<a href="{% url "maintainer" maintainer.id %}">
{{ maintainer.email }}
</a>
{% endif %}
{% endfor %}
</dd>
{% endif %}
{% if packaged %}
<dt>Packaged Versions</dt>
<dd>
<ul>
{% for version in packaged %}
<li id="{{ version.version }}-{{version.revision }}:{{ version.slot }}-[{{ version.overlay }}]">
{% if version.overlay == "gentoo" %}
<img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="In Gentoo" />
{% else %}
<img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="In Overlays" />
{% endif %}
{% if version.vtype and not version.vtype|is_stable %}
<img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" />
{% endif %}
{{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}]
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
{% if upstream %}
<dt>Upstream versions</dt>
<dd>
<ul>
{% for version in upstream %}
<li>
<img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Upstream" />
{% if version.vtype and not version.vtype|is_stable %}
<img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" />
{% endif %}
{{ version.version }} - {{ version.urls }}
{% if confidence < 100 %}({{ version.confidence }}%){% endif %}
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
{% if vlog %}
<dt>Version history</dt>
<dd>
<ul class="log">
{% for version in vlog %}
{% if version.action == version.VERSION_ADDED %}
<li class="added">
{% else %}
<li class="removed">
{% endif %}
{% if version.overlay == "gentoo" %}
<img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="In Gentoo" />
{% elif version.overlay %}
<img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="In Overlays" />
{% else %}
<img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Upstream" />
{% endif %}
{% if version.vtype and not version.vtype|is_stable %}
<img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" />
{% endif %}
{{ version }} - {{ version.datetime }}
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
{% if log %}
<dt>euscan log</dt>
<dd>
<p>Date: {{ log.datetime }}
<pre class="log">{{ msg|ansi_to_html|safe }}</pre>
</dd>
{% endif %}
</dl>

View File

@ -1,7 +1,6 @@
{% extends "euscan/_datatable.html" %}
{% load sub %}
{% load djeuscan_helpers %}
{% load url from future %}
{% block meta %}
@ -26,12 +25,6 @@
{% block content %}
{% if thanks_for_reporting %}
<div class="alert alert-success">
<strong>Thanks!</strong> Your report has been sent to admins
</div>
{% endif %}
<div class="refresh-alert alert {% if not refreshed %}hide{% endif %}">
A refresh request is in progress, please wait...
</div>
@ -56,158 +49,18 @@
</span>
{% endif %}
</h2>
<dl>
{% if package.description %}
<dt>Description</dt>
<dd>{{ package.description }}</dd>
{% endif %}
{% if package.homepage %}
<dt>Homepage</dt>
<dd>
{% for homepage in package.homepages %}
<a href="{{ homepage }}">{{ homepage }}</a><br />
{% endfor %}
</dd>
{% endif %}
{% if package.herds.all %}
<dt>Herds</dt>
<dd>
{% for herd in package.herds.all %}
<a href="{% url "herd" herd.herd %}">
{{ herd.herd }}
</a>
&lt;{{ herd.email }}&gt;
{% endfor %}
</dd>
{% endif %}
{% if package.maintainers.all %}
<dt>Maintainers</dt>
<dd>
{% for maintainer in package.maintainers.all %}
{% if maintainer.name != maintainer.email %}
<a href="{% url "maintainer" maintainer.id %}">
{{ maintainer.name }}
</a>
&lt;{{ maintainer.email }}&gt;
{% else %}
<a href="{% url "maintainer" maintainer.id %}">
{{ maintainer.email }}
</a>
{% endif %}
{% endfor %}
</dd>
{% endif %}
{% if packaged %}
<dt>Packaged Versions</dt>
<dd>
<ul>
{% for version in packaged %}
<li id="{{ version.version }}-{{version.revision }}:{{ version.slot }}-[{{ version.overlay }}]">
{% if version.overlay == "gentoo" %}
<img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="In Gentoo" />
{% else %}
<img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="In Overlays" />
{% endif %}
{% if version.vtype and not version.vtype|is_stable %}
<img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" />
{% endif %}
{{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}]
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
{% if upstream %}
<dt>Upstream versions</dt>
<dd>
<ul>
{% for version in upstream %}
<li>
<img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Upstream" />
{% if version.vtype and not version.vtype|is_stable %}
<img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" />
{% endif %}
{{ version.version }} - {{ version.urls }}
{% if confidence < 100 %}({{ version.confidence }}%){% endif %}
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
<dt>Version history</dt>
<dd>
<ul class="log">
{% for version in vlog %}
{% if version.action == version.VERSION_ADDED %}
<li class="added">
{% else %}
<li class="removed">
{% endif %}
{% if version.overlay == "gentoo" %}
<img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="In Gentoo" />
{% elif version.overlay %}
<img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="In Overlays" />
{% else %}
<img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Upstream" />
{% endif %}
{% if version.vtype and not version.vtype|is_stable %}
<img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" />
{% endif %}
{{ version }} - {{ version.datetime }}
</li>
{% endfor %}
</ul>
</dt>
{% if log %}
<dt>euscan log</dt>
<dd>
<p>Date: {{ log.datetime }}
<pre class="log">{{ msg|ansi_to_html|safe }}</pre>
</dd>
{% endif %}
</dl>
{% include "euscan/_package_details.html" %}
<hr/>
<h3 class="report-problems-toggle cursor-pointer">Report problems</h3>
<div class="report-problems hide">
<form action="." method="post" class="form-horizontal">
<div class="control-group {% if problem_form.version.errors %}error{% endif %}">
<label class="control-label" for="version">{{ problem_form.version.label }}</label>
<div class="controls">
{{ problem_form.version }}
<span class="help-inline">{{ problem_form.version.errors.as_text }}</span>
</div>
</div>
<div class="control-group {% if problem_form.subject.errors %}error{% endif %}">
<label class="control-label" for="subject">{{ problem_form.subject.label }}</label>
<div class="controls">
{{ problem_form.subject }}
<span class="help-inline">{{ problem_form.subject.errors.as_text }}</span>
</div>
</div>
<div class="control-group {% if problem_form.message.errors %}error{% endif %}">
<label class="control-label" for="message">{{ problem_form.message.label }}</label>
<div class="controls">
{{ problem_form.message }}
<span class="help-inline">{{ problem_form.message.errors.as_text }}</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<input class="btn" type="submit" value="Submit" />
</div>
</div>
{% if user.is_authenticated %}
<form class="pull-right" action="{% url "problem" package.category package.name %}" method="get">
<button class="btn bug-button">
<img src="{{ STATIC_URL}}/img/bug.png" alt="Report problems" >
</button>
</form>
</div>
{% endif %}
<script type="text/javascript">
$(document).ready(function () {
@ -235,10 +88,6 @@
});
});
$(".report-problems-toggle").click(function () {
$(".report-problems").toggle("slow");
});
});
</script>

View File

@ -0,0 +1,57 @@
{% extends "euscan/_datatable.html" %}
{% load sub %}
{% load djeuscan_helpers %}
{% load url from future %}
{% block title %}
{{ block.super }} - Report Problem: {{ package.category }}/{{ package.name }}
{% endblock %}
{% block content %}
{% if thanks_for_reporting %}
<div class="alert alert-success">
<strong>Thanks!</strong> Your report has been sent to admins
</div>
{% endif %}
<h2>
Report Problem: {{ package.category }}/{{ package.name }}
</h2>
{% include "euscan/_package_details.html" %}
<hr/>
<div class="report-problems">
<form action="{% url "problem" package.category package.name %}" method="post" class="form-horizontal">
<div class="control-group {% if form.version.errors %}error{% endif %}">
<label class="control-label" for="version">{{ form.version.label }}</label>
<div class="controls">
{{ form.version }}
<span class="help-inline">{{ form.version.errors.as_text }}</span>
</div>
</div>
<div class="control-group {% if form.subject.errors %}error{% endif %}">
<label class="control-label" for="subject">{{ form.subject.label }}</label>
<div class="controls">
{{ form.subject }}
<span class="help-inline">{{ form.subject.errors.as_text }}</span>
</div>
</div>
<div class="control-group {% if form.message.errors %}error{% endif %}">
<label class="control-label" for="message">{{ form.message.label }}</label>
<div class="controls">
{{ form.message }}
<span class="help-inline">{{ form.message.errors.as_text }}</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<input class="btn" type="submit" value="Submit" />
</div>
</div>
</form>
</div>
{% endblock %}

View File

@ -22,6 +22,8 @@ package_patterns = patterns('djeuscan.views',
'unfavourite/$'), 'unfavourite_package', name="unfavourite_package"),
url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/'
'refresh$'), "refresh_package", name="refresh_package"),
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/problem$',
'problem', name="problem"),
)
categories_patterns = patterns('djeuscan.views',

View File

@ -1,7 +1,6 @@
""" Views """
import inspect
import json
from annoying.decorators import render_to, ajax_request
from django.http import Http404
@ -188,7 +187,6 @@ def overlay(request, overlay):
return {'overlay': overlay, 'packages': packages, 'last_scan': last_scan,
'favourited': favourited}
@render_to('euscan/package.html')
def package(request, category, package):
package = get_object_or_404(Package, category=category, name=package)
@ -203,13 +201,6 @@ def package(request, category, package):
log = log[0] if log else None
vlog = VersionLog.objects.for_package(package, order=True)
result = json.loads(log.result) if log else None
if result and package.cp() in result:
msg = result[package.cp()]['messages']
else:
msg = ""
try:
last_scan = EuscanResult.objects.for_package(package).latest().datetime
except EuscanResult.DoesNotExist:
@ -230,42 +221,62 @@ def package(request, category, package):
except RefreshPackageQuery.DoesNotExist:
refreshed = False
thanks_for_reporting = False
if request.method == "POST":
problem_form = ProblemReportForm(package, request.POST)
if problem_form.is_valid():
ProblemReport(
package=package,
version=problem_form.cleaned_data["version"],
subject=problem_form.cleaned_data["subject"],
message=problem_form.cleaned_data["message"],
).save()
thanks_for_reporting = True
else:
problem_form = ProblemReportForm(package)
return {
'package': package,
'packaged': packaged,
'upstream': upstream,
'log': log,
'log': log.messages(),
'vlog': vlog,
'msg': msg,
'msg' : log.messages() if log else "",
'last_scan': last_scan,
'favourited': favourited,
'refreshed': refreshed,
'problem_form': problem_form,
'thanks_for_reporting': thanks_for_reporting
}
@login_required
@render_to('euscan/problem.html')
def problem(request, category, package):
package = get_object_or_404(Package, category=category, name=package)
packaged = Version.objects.filter(package=package, packaged=True)
upstream = Version.objects.filter(package=package, packaged=False)
log = EuscanResult.objects.filter(package=package).\
order_by('-datetime')[:1]
log = log[0] if log else None
thanks_for_reporting = False
if request.method == "POST":
form = ProblemReportForm(package, request.POST)
if form.is_valid():
ProblemReport(
package=package,
version=form.cleaned_data["version"],
subject=form.cleaned_data["subject"],
message=form.cleaned_data["message"],
).save()
thanks_for_reporting = True
else:
form = ProblemReportForm(package)
return {
'form': form,
'thanks_for_reporting': thanks_for_reporting,
'package': package,
'packaged': packaged,
'upstream': upstream,
'msg' : log.messages() if log else "",
}
@render_to('euscan/world.html')
def world(request):
world_form = WorldForm()
packages_form = PackagesForm()
return {'world_form': world_form,
'packages_form': packages_form}
return {
'world_form': world_form,
'packages_form': packages_form
}
@render_to('euscan/world_scan.html')

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B