summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-18 10:14:28 -0600
committerDan McGee <dan@archlinux.org>2011-01-18 10:21:47 -0600
commit487daf1c72f86a064b659f68d9f7722706997ab2 (patch)
tree11240c6831e3dfac969b4b4fd02fa28710d6f991
parentb66f11dedfc86dfd35b09b0d0c86f0d8f60bf412 (diff)
Make package signoffs AJAX if JS is enabled
This makes the signoffs page a heck of a lot more usable as you can go through and click a bunch at once without waiting for the rather slow page to reload. Hopefully the first step to bringing life back into this part of the site. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--media/archweb.js23
-rw-r--r--packages/urls.py2
-rw-r--r--packages/views.py30
-rw-r--r--templates/packages/signoffs.html7
4 files changed, 45 insertions, 17 deletions
diff --git a/media/archweb.js b/media/archweb.js
index b2f3af2a..b7351878 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 da24ee03..c9006a12 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 77fa3a07..4e683144 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 8d78c8a1..0cb7679c 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 %}