diff options
-rw-r--r-- | templates/todolists/view.html | 5 | ||||
-rw-r--r-- | todolists/urls.py | 3 | ||||
-rw-r--r-- | todolists/views.py | 31 |
3 files changed, 30 insertions, 9 deletions
diff --git a/templates/todolists/view.html b/templates/todolists/view.html index 6516f73..d45905e 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -23,6 +23,11 @@ <div>{{list.description|urlize|linebreaks}}</div> + <p>Link to lists of pkgbase values:</p> + <ul>{% for svn_root in svn_roots %} + <li><a href="pkgbases/{{ svn_root }}/">{{ svn_root }}</a></li> + {% endfor %}</ul> + <table id="dev-todo-pkglist" class="results todo-table"> <thead> <tr> diff --git a/todolists/urls.py b/todolists/urls.py index 2612a52..0bd8817 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<list_id>\d+)/$', 'view'), + (r'^(?P<list_id>\d+)/pkgbases/(?P<svn_root>[a-z]+)/$', 'list_pkgbases'), (r'^add/$', 'add'), (r'^edit/(?P<list_id>\d+)/$', 'edit'), (r'^flag/(\d+)/(\d+)/$', 'flag'), diff --git a/todolists/views.py b/todolists/views.py index 585cefd..d413ca4 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 |