From 7b7dcfaa7c1b10d4f595a68e4136f30162930011 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 4 Jan 2012 12:15:29 -0600 Subject: Add new todolist pkgbase list view This is for use after rebuilds when moving packages out of the staging and testing repositories. Signed-off-by: Dan McGee --- templates/todolists/view.html | 5 +++++ todolists/urls.py | 3 ++- todolists/views.py | 31 +++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/templates/todolists/view.html b/templates/todolists/view.html index 6516f73e..d45905e3 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -23,6 +23,11 @@
{{list.description|urlize|linebreaks}}
+

Link to lists of pkgbase values:

+ + diff --git a/todolists/urls.py b/todolists/urls.py index 2612a52e..0bd8817b 100644 --- a/todolists/urls.py +++ b/todolists/urls.py @@ -5,7 +5,8 @@ from .views import DeleteTodolist urlpatterns = patterns('todolists.views', (r'^$', 'todolist_list'), - (r'^(\d+)/$', 'view'), + (r'^(?P\d+)/$', 'view'), + (r'^(?P\d+)/pkgbases/(?P[a-z]+)/$', 'list_pkgbases'), (r'^add/$', 'add'), (r'^edit/(?P\d+)/$', 'edit'), (r'^flag/(\d+)/(\d+)/$', 'flag'), diff --git a/todolists/views.py b/todolists/views.py index 585cefd0..d413ca47 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -2,7 +2,7 @@ from django import forms from django.http import HttpResponse from django.core.mail import send_mail -from django.shortcuts import get_object_or_404, redirect +from django.shortcuts import get_list_or_404, get_object_or_404, redirect from django.contrib.auth.decorators import login_required, permission_required from django.db import transaction from django.views.decorators.cache import never_cache @@ -11,7 +11,7 @@ from django.views.generic.simple import direct_to_template from django.template import Context, loader from django.utils import simplejson -from main.models import Todolist, TodolistPkg, Package +from main.models import Todolist, TodolistPkg, Package, Repo from packages.utils import attach_maintainers from .utils import get_annotated_todolists @@ -35,9 +35,9 @@ class TodoListForm(forms.ModelForm): @permission_required('main.change_todolistpkg') @never_cache -def flag(request, listid, pkgid): - todolist = get_object_or_404(Todolist, id=listid) - pkg = get_object_or_404(TodolistPkg, id=pkgid) +def flag(request, list_id, pkg_id): + todolist = get_object_or_404(Todolist, id=list_id) + pkg = get_object_or_404(TodolistPkg, id=pkg_id) pkg.complete = not pkg.complete pkg.save() if request.is_ajax(): @@ -48,12 +48,27 @@ def flag(request, listid, pkgid): @login_required @never_cache -def view(request, listid): - todolist = get_object_or_404(Todolist, id=listid) +def view(request, list_id): + todolist = get_object_or_404(Todolist, id=list_id) + svn_roots = Repo.objects.order_by().values_list( + 'svn_root', flat=True).distinct() # we don't hold onto the result, but the objects are the same here, # so accessing maintainers in the template is now cheap attach_maintainers(tp.pkg for tp in todolist.packages) - return direct_to_template(request, 'todolists/view.html', {'list': todolist}) + return direct_to_template(request, 'todolists/view.html', { + 'list': todolist, + 'svn_roots': svn_roots, + }) + +# really no need for login_required on this one... +def list_pkgbases(request, list_id, svn_root): + '''Used to make bulk moves of packages a lot easier.''' + todolist = get_object_or_404(Todolist, id=list_id) + repos = get_list_or_404(Repo, svn_root=svn_root) + pkgbases = set(tp.pkg.pkgbase for tp in todolist.packages + if tp.pkg.repo in repos) + return HttpResponse('\n'.join(sorted(pkgbases)), + mimetype='text/plain') @login_required @never_cache -- cgit v1.2.3-2-g168b