summaryrefslogtreecommitdiff
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
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>
-rw-r--r--packages/urls.py1
-rw-r--r--packages/views.py13
-rw-r--r--templates/packages/stale_relations.html23
3 files changed, 31 insertions, 6 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:
diff --git a/templates/packages/stale_relations.html b/templates/packages/stale_relations.html
index 975ef1b6..8e2f8930 100644
--- a/templates/packages/stale_relations.html
+++ b/templates/packages/stale_relations.html
@@ -6,11 +6,13 @@
<div class="box">
<h2>Stale Package Relations</h2>
+ <form id="stale-relations-form" method="post" action="update/">{% csrf_token %}
<h3>Inactive User Relations ({{ inactive_user|length }})</h3>
<table class="results" id="inactive-user">
<thead>
<tr>
+ <th>&nbsp;</th>
<th>Package Base</th>
<th>Packages</th>
<th>User</th>
@@ -20,6 +22,7 @@
<tbody>
{% for relation in inactive_user %}
<tr class="{% cycle 'odd' 'even' %}">
+ <td><input type="checkbox" name="relation_id" value="{{ relation.id }}" /></td>
<td>{{ relation.pkgbase }}</td>
<td class="wrap">{% for pkg in relation.get_associated_packages %}
<a href="{{ pkg.get_absolute_url }}"
@@ -29,7 +32,7 @@
<td>{{ relation.get_type_display }}</td>
</tr>
{% empty %}
- <tr class="empty"><td colspan="3"><em>No inactive user relations.</em></td></tr>
+ <tr class="empty"><td colspan="5"><em>No inactive user relations.</em></td></tr>
{% endfor %}
</tbody>
</table>
@@ -39,6 +42,7 @@
<table class="results" id="missing-pkgbase">
<thead>
<tr>
+ <th>&nbsp;</th>
<th>Package Base</th>
<th>User</th>
<th>Type</th>
@@ -47,12 +51,13 @@
<tbody>
{% for relation in missing_pkgbase %}
<tr class="{% cycle 'odd' 'even' %}">
+ <td><input type="checkbox" name="relation_id" value="{{ relation.id }}" /></td>
<td>{{ relation.pkgbase }}</td>
<td>{{ relation.user.get_full_name }}</td>
<td>{{ relation.get_type_display }}</td>
</tr>
{% empty %}
- <tr class="empty"><td colspan="3"><em>No non-existent pkgbase relations.</em></td></tr>
+ <tr class="empty"><td colspan="4"><em>No non-existent pkgbase relations.</em></td></tr>
{% endfor %}
</tbody>
</table>
@@ -62,6 +67,7 @@
<table class="results" id="wrong-permissions">
<thead>
<tr>
+ <th>&nbsp;</th>
<th>Package Base</th>
<th>Packages</th>
<th>User</th>
@@ -72,6 +78,7 @@
<tbody>
{% for relation in wrong_permissions %}
<tr class="{% cycle 'odd' 'even' %}">
+ <td><input type="checkbox" name="relation_id" value="{{ relation.id }}" /></td>
<td>{{ relation.pkgbase }}</td>
<td class="wrap">{% for pkg in relation.get_associated_packages %}
<a href="{{ pkg.get_absolute_url }}"
@@ -82,20 +89,24 @@
<td class="wrap">{{ relation.repositories|join:", " }}</td>
</tr>
{% empty %}
- <tr class="empty"><td colspan="3"><em>No relations with wrong permissions.</em></td></tr>
+ <tr class="empty"><td colspan="6"><em>No relations with wrong permissions.</em></td></tr>
{% endfor %}
</tbody>
</table>
+ <p><input title="Delete selected relations" type="submit" id="delete-relations"
+ name="delete" value="Delete Selected Relations" />
+ </form>
+
</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() {
- $('#inactive-user:not(:has(tbody tr.empty))').tablesorter({widgets: ['zebra'], sortList: [[2,0]]});
- $('#missing-pkgbase:not(:has(tbody tr.empty))').tablesorter({widgets: ['zebra'], sortList: [[0,0]]});
+ $('#inactive-user:not(:has(tbody tr.empty))').tablesorter({widgets: ['zebra'], headers: { 0: { sorter: false } }, sortList: [[3,0]]});
+ $('#missing-pkgbase:not(:has(tbody tr.empty))').tablesorter({widgets: ['zebra'], headers: { 0: { sorter: false } }, sortList: [[1,0]]});
});
- $('#wrong-permissions:not(:has(tbody tr.empty))').tablesorter({widgets: ['zebra'], sortList: [[2,0]]});
+ $('#wrong-permissions:not(:has(tbody tr.empty))').tablesorter({widgets: ['zebra'], headers: { 0: { sorter: false } }, sortList: [[3,0]]});
</script>
{% endblock %}