From a12e2c42ea4f449fb3d12bb13a64c232468eb6d6 Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Wed, 25 Jul 2012 16:52:10 +0200 Subject: [PATCH] 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 --- euscanwww/djeuscan/models.py | 10 ++ .../templates/euscan/_package_details.html | 122 +++++++++++++ .../djeuscan/templates/euscan/package.html | 167 +----------------- .../djeuscan/templates/euscan/problem.html | 57 ++++++ euscanwww/djeuscan/urls.py | 2 + euscanwww/djeuscan/views.py | 69 +++++--- euscanwww/htdocs/img/bug.png | Bin 0 -> 925 bytes 7 files changed, 239 insertions(+), 188 deletions(-) create mode 100644 euscanwww/djeuscan/templates/euscan/_package_details.html create mode 100644 euscanwww/djeuscan/templates/euscan/problem.html create mode 100644 euscanwww/htdocs/img/bug.png diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index 0c38909..6626a41 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -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 diff --git a/euscanwww/djeuscan/templates/euscan/_package_details.html b/euscanwww/djeuscan/templates/euscan/_package_details.html new file mode 100644 index 0000000..1e04911 --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/_package_details.html @@ -0,0 +1,122 @@ +{% load djeuscan_helpers %} +{% load url from future %} + +
+ {% if package.description %} +
Description
+
{{ package.description }}
+ {% endif %} + {% if package.homepage %} +
Homepage
+
+ {% for homepage in package.homepages %} + {{ homepage }}
+ {% endfor %} +
+ {% endif %} + {% if package.herds.all %} +
Herds
+
+ {% for herd in package.herds.all %} + + {{ herd.herd }} + + <{{ herd.email }}> + {% endfor %} +
+ {% endif %} + {% if package.maintainers.all %} +
Maintainers
+
+ {% for maintainer in package.maintainers.all %} + {% if maintainer.name != maintainer.email %} + + {{ maintainer.name }} + + <{{ maintainer.email }}> + {% else %} + + {{ maintainer.email }} + + {% endif %} + {% endfor %} +
+ {% endif %} + {% if packaged %} +
Packaged Versions
+
+
    + {% for version in packaged %} +
  • + {% if version.overlay == "gentoo" %} + gentoo + {% else %} + overlays + {% endif %} + + {% if version.vtype and not version.vtype|is_stable %} + unstable + {% endif %} + + {{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}] +
  • + {% endfor %} +
+
+ {% endif %} + {% if upstream %} +
Upstream versions
+
+
    + {% for version in upstream %} +
  • + upstream + + {% if version.vtype and not version.vtype|is_stable %} + unstable + {% endif %} + + {{ version.version }} - {{ version.urls }} + {% if confidence < 100 %}({{ version.confidence }}%){% endif %} +
  • + {% endfor %} +
+
+ {% endif %} + {% if vlog %} +
Version history
+
+
    + {% for version in vlog %} + {% if version.action == version.VERSION_ADDED %} +
  • + {% else %} +
  • + {% endif %} + {% if version.overlay == "gentoo" %} + gentoo + {% elif version.overlay %} + overlays + {% else %} + upstream + {% endif %} + + {% if version.vtype and not version.vtype|is_stable %} + unstable + {% endif %} + + {{ version }} - {{ version.datetime }} + +
  • + {% endfor %} +
+
+ {% endif %} + {% if log %} +
euscan log
+
+

Date: {{ log.datetime }} +

{{ msg|ansi_to_html|safe }}
+
+ {% endif %} +
diff --git a/euscanwww/djeuscan/templates/euscan/package.html b/euscanwww/djeuscan/templates/euscan/package.html index 2357318..8c90efe 100644 --- a/euscanwww/djeuscan/templates/euscan/package.html +++ b/euscanwww/djeuscan/templates/euscan/package.html @@ -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 %} -
- Thanks! Your report has been sent to admins -
-{% endif %} -
A refresh request is in progress, please wait...
@@ -56,158 +49,18 @@ {% endif %} -
- {% if package.description %} -
Description
-
{{ package.description }}
- {% endif %} - {% if package.homepage %} -
Homepage
-
- {% for homepage in package.homepages %} - {{ homepage }}
- {% endfor %} -
- {% endif %} - {% if package.herds.all %} -
Herds
-
- {% for herd in package.herds.all %} - - {{ herd.herd }} - - <{{ herd.email }}> - {% endfor %} -
- {% endif %} - {% if package.maintainers.all %} -
Maintainers
-
- {% for maintainer in package.maintainers.all %} - {% if maintainer.name != maintainer.email %} - - {{ maintainer.name }} - - <{{ maintainer.email }}> - {% else %} - - {{ maintainer.email }} - - {% endif %} - {% endfor %} -
- {% endif %} - {% if packaged %} -
Packaged Versions
-
-
    - {% for version in packaged %} -
  • - {% if version.overlay == "gentoo" %} - gentoo - {% else %} - overlays - {% endif %} - {% if version.vtype and not version.vtype|is_stable %} - unstable - {% endif %} - - {{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}] -
  • - {% endfor %} -
-
- {% endif %} - {% if upstream %} -
Upstream versions
-
-
    - {% for version in upstream %} -
  • - upstream - - {% if version.vtype and not version.vtype|is_stable %} - unstable - {% endif %} - - {{ version.version }} - {{ version.urls }} - {% if confidence < 100 %}({{ version.confidence }}%){% endif %} -
  • - {% endfor %} -
-
- {% endif %} -
Version history
-
-
    - {% for version in vlog %} - {% if version.action == version.VERSION_ADDED %} -
  • - {% else %} -
  • - {% endif %} - {% if version.overlay == "gentoo" %} - gentoo - {% elif version.overlay %} - overlays - {% else %} - upstream - {% endif %} - - {% if version.vtype and not version.vtype|is_stable %} - unstable - {% endif %} - - {{ version }} - {{ version.datetime }} - -
  • - {% endfor %} -
- - {% if log %} -
euscan log
-
-

Date: {{ log.datetime }} -

{{ msg|ansi_to_html|safe }}
-
- {% endif %} -
+{% include "euscan/_package_details.html" %}
-

Report problems

-
-
-
- -
- {{ problem_form.version }} - {{ problem_form.version.errors.as_text }} -
-
-
- -
- {{ problem_form.subject }} - {{ problem_form.subject.errors.as_text }} -
-
-
- -
- {{ problem_form.message }} - {{ problem_form.message.errors.as_text }} -
-
- -
-
- -
-
-
-
+{% if user.is_authenticated %} +
+ +
+{% endif %} diff --git a/euscanwww/djeuscan/templates/euscan/problem.html b/euscanwww/djeuscan/templates/euscan/problem.html new file mode 100644 index 0000000..828b7ab --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/problem.html @@ -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 %} +
+ Thanks! Your report has been sent to admins +
+{% endif %} + +

+ Report Problem: {{ package.category }}/{{ package.name }} +

+ +{% include "euscan/_package_details.html" %} +
+
+
+
+ +
+ {{ form.version }} + {{ form.version.errors.as_text }} +
+
+
+ +
+ {{ form.subject }} + {{ form.subject.errors.as_text }} +
+
+
+ +
+ {{ form.message }} + {{ form.message.errors.as_text }} +
+
+ +
+
+ +
+
+
+
+ +{% endblock %} diff --git a/euscanwww/djeuscan/urls.py b/euscanwww/djeuscan/urls.py index e4611d7..b1b1f88 100644 --- a/euscanwww/djeuscan/urls.py +++ b/euscanwww/djeuscan/urls.py @@ -22,6 +22,8 @@ package_patterns = patterns('djeuscan.views', 'unfavourite/$'), 'unfavourite_package', name="unfavourite_package"), url((r'^(?P[\w+][\w+.-]*)/(?P[\w+][\w+.-]*)/' 'refresh$'), "refresh_package", name="refresh_package"), + url(r'^(?P[\w+][\w+.-]*)/(?P[\w+][\w+.-]*)/problem$', + 'problem', name="problem"), ) categories_patterns = patterns('djeuscan.views', diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index 3d96cb0..c9abfca 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -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') diff --git a/euscanwww/htdocs/img/bug.png b/euscanwww/htdocs/img/bug.png new file mode 100644 index 0000000000000000000000000000000000000000..c33bfb9cfd4a9d6d242c38dc8fe5d192fc3f831e GIT binary patch literal 925 zcmV;O17iG%P)OpREm=>0CEf<6dKeK8bzA_NsB zJrK%*UWgS$StNn>A+R8%LLn$9=tB_}o&F>BMO<}*4jj(8_n!IPbIzP$7!i%A5Y>*V z5H8(WTBsv|oQO#)&BrO=CL#78YMwJcBuybxSN)1jYeb#8` zTjyg+78cU7!ZL z9uEWp^dKB=9yj=~q8xY>4AL=VYyz}ar=zC`y$36y1?pZ~Ru=Uo5_Hbt*gh^WgqteK zN3MiIbQi}@Q1UC)Lf-&(1wC(r_F&yvTugCEsv9p@GMmlyNw?=?5aqT2{19R7usvEW zb-}*~KZ2}N;Ygp=YQ_CbJ0=(-HzO1Z?O7&>4HGeL31ruZu)VO`06qhM3H$=QxJ?FS zGsdhHU|~#fG#X9j=H?zkFu#=JpCpl8J;K(*t^{}={B@|LR?rV+>TozPKo)0Ouqya~ z=7+=Kql%)K|9&*(OxwPVaf5XTU5g&CVBGf#rfpNtpq$ZYoZ|QUkH+KiNII|@v~c+E zNL^27tQ3EZb1{wPq=&I-Bg6<^uXo;X@PE