diff options
-rw-r--r-- | media/archweb.js | 23 | ||||
-rw-r--r-- | packages/urls.py | 2 | ||||
-rw-r--r-- | packages/views.py | 30 | ||||
-rw-r--r-- | templates/packages/signoffs.html | 7 |
4 files changed, 45 insertions, 17 deletions
diff --git a/media/archweb.js b/media/archweb.js index b2f3af2..b735187 100644 --- a/media/archweb.js +++ b/media/archweb.js @@ -154,3 +154,26 @@ function todolist_flag() { }); return false; } + +/* signoffs.html */ +function signoff_package() { + var link = this; + $.getJSON(link.href, function(data) { + if (data.created) { + var signoff = $('<li>').addClass('signed-username').text(data.user); + $(link).append(signoff); + } + /* update the approved column to reflect reality */ + if (data.approved) { + var approved = $(link).closest('tr').children('.signoff-no'); + approved.text('Yes').addClass( + 'signoff-yes').removeClass('signoff-no'); + } else { + var approved = $(link).closest('tr').children('.signoff-yes'); + approved.text('No').addClass( + 'signoff-no').removeClass('signoff-yes'); + } + $('.results').trigger('updateCell', approved); + }); + return false; +} diff --git a/packages/urls.py b/packages/urls.py index da24ee0..c9006a1 100644 --- a/packages/urls.py +++ b/packages/urls.py @@ -11,7 +11,7 @@ package_patterns = patterns('packages.views', urlpatterns = patterns('packages.views', (r'^flaghelp/$', 'flaghelp'), - (r'^signoffs/$', 'signoffs'), + (r'^signoffs/$', 'signoffs', {}, 'package-signoffs'), (r'^signoff_package/(?P<arch>[A-z0-9]+)/(?P<pkgname>[A-z0-9\-+.]+)/$', 'signoff_package'), (r'^update/$', 'update'), diff --git a/packages/views.py b/packages/views.py index 77fa3a0..4e68314 100644 --- a/packages/views.py +++ b/packages/views.py @@ -1,18 +1,19 @@ from django import forms from django.contrib import messages +from django.contrib.admin.widgets import AdminDateWidget +from django.contrib.auth.models import User +from django.contrib.auth.decorators import permission_required from django.conf import settings from django.core.mail import send_mail -from django.template import loader, Context, RequestContext +from django.db.models import Q from django.http import HttpResponse, Http404 from django.shortcuts import get_object_or_404, redirect -from django.contrib.auth.models import User -from django.contrib.auth.decorators import permission_required -from django.contrib.admin.widgets import AdminDateWidget +from django.template import loader, Context, RequestContext +from django.utils import simplejson from django.views.decorators.cache import never_cache from django.views.decorators.vary import vary_on_headers from django.views.generic import list_detail from django.views.generic.simple import direct_to_template -from django.db.models import Q from datetime import datetime import string @@ -276,15 +277,16 @@ def signoff_package(request, arch, pkgname): pkgrel=pkg.pkgrel, packager=request.user) - if created: - messages.info(request, - "You have successfully signed off for %s on %s." % \ - (pkg.pkgname, pkg.arch)) - else: - messages.warning(request, - "You have already signed off for %s on %s." % \ - (pkg.pkgname, pkg.arch)) - return signoffs(request) + if request.is_ajax(): + data = { + 'created': created, + 'approved': pkg.approved_for_signoff(), + 'user': str(request.user), + } + return HttpResponse(simplejson.dumps(data), + mimetype='application/json') + + return redirect('package-signoffs') def flaghelp(request): return direct_to_template(request, 'packages/flaghelp.html') diff --git a/templates/packages/signoffs.html b/templates/packages/signoffs.html index 8d78c8a..0cb7679 100644 --- a/templates/packages/signoffs.html +++ b/templates/packages/signoffs.html @@ -33,7 +33,7 @@ {{ pkg.approved_for_signoff|yesno:"Yes,No" }}</td> <td> <ul> - <li><a href="/packages/signoff_package/{{pkg.arch}}/{{pkg.pkgname}}/" + <li><a class="signoff-link" href="/packages/signoff_package/{{pkg.arch}}/{{pkg.pkgname}}/" title="Signoff {{pkg.pkgname}} for {{pkg.arch}}">Signoff</a> </li> {% for signoff in pkg.signoffs %} @@ -49,9 +49,12 @@ </div> {% load cdn %}{% jquery %} <script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script> +<script type="text/javascript" src="/media/archweb.js"></script> <script type="text/javascript"> $(document).ready(function() { - $(".results").tablesorter({widgets: ['zebra'], sortList: [[1,0]]}); + $('a.signoff-link').click(signoff_package); + $(".results").tablesorter({widgets: ['zebra'], sortList: [[1,0]], + headers: { 6: { sorter: false } } }); }); </script> {% endif %} |