summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-23 12:36:49 -0600
committerDan McGee <dan@archlinux.org>2011-02-23 12:36:49 -0600
commit93bca8b0ed79afc30f6237e13dacaf32ed8cd4b3 (patch)
tree27bd36d48aa8918838f604c491a04f4417524978 /packages
parent3181e970ce9dcc4fd996499ee536e4c2454e89dd (diff)
Allow deleting of stale package relations via status page
Add a column of checkboxes to each table, enclose the whole thing in a form, and add a super-simple delete view that takes a list of IDs and removes them from the database. The delete_packagerelation permission is required to be able to delete relations. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r--packages/urls.py1
-rw-r--r--packages/views.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/packages/urls.py b/packages/urls.py
index 37ce23c0..638a370a 100644
--- a/packages/urls.py
+++ b/packages/urls.py
@@ -26,6 +26,7 @@ urlpatterns = patterns('packages.views',
(r'^differences/$', 'arch_differences'),
(r'^stale_relations/$', 'stale_relations'),
+ (r'^stale_relations/update/$','stale_relations_update'),
(r'^(?P<name>[A-z0-9\-+.]+)/$',
'details'),
diff --git a/packages/views.py b/packages/views.py
index 9a2094aa..1ab04258 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -11,6 +11,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.template import loader, Context, RequestContext
from django.utils import simplejson
from django.views.decorators.cache import never_cache
+from django.views.decorators.http import require_POST
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
@@ -36,6 +37,7 @@ def opensearch(request):
mimetype='application/opensearchdescription+xml')
@permission_required('main.change_package')
+@require_POST
def update(request):
ids = request.POST.getlist('pkgid')
count = 0
@@ -418,4 +420,15 @@ def stale_relations(request):
}
return direct_to_template(request, 'packages/stale_relations.html', context)
+@permission_required('packages.delete_packagerelation')
+@require_POST
+def stale_relations_update(request):
+ ids = set(request.POST.getlist('relation_id'))
+
+ if ids:
+ PackageRelation.objects.filter(id__in=ids).delete()
+
+ messages.info(request, "%d package relations deleted." % len(ids))
+ return redirect('/packages/stale_relations/')
+
# vim: set ts=4 sw=4 et: