diff options
author | Dan McGee <dan@archlinux.org> | 2013-01-22 16:47:43 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2013-01-22 16:47:43 -0600 |
commit | e9e1c071654edd7b95e20c8105abbc23f426cecc (patch) | |
tree | 3becfd32ef3535d15504d98fff68969787634a0e | |
parent | 53484c45ea82a5afa8bf167f978f657b866d4c93 (diff) |
Show staging version on todolist view page
If one exists, it is easy enough to show it here so in-progress
todolists can easily be cross-checked with the current state of the
repository.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | templates/todolists/view.html | 5 | ||||
-rw-r--r-- | todolists/utils.py | 19 | ||||
-rw-r--r-- | todolists/views.py | 3 |
3 files changed, 26 insertions, 1 deletions
diff --git a/templates/todolists/view.html b/templates/todolists/view.html index 86221127..e544fa12 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static from staticfiles %} +{% load package_extras %} {% load todolists %} {% block title %}Arch Linux - Todo: {{ list.name }}{% endblock %} @@ -62,6 +63,7 @@ <th>Repository</th> <th>Name</th> <th>Current Version</th> + <th>Staging Version</th> <th>Maintainers</th> <th>Status</th> </tr> @@ -77,6 +79,9 @@ {% else %} <td>{{ pkg.pkg.full_version }}</td> {% endif %} + {% with staging=pkg.staging %} + <td>{% pkg_details_link staging staging.full_version %}</td> + {% endwith %} <td>{{ pkg.maintainers|join:', ' }}</td> <td> {% if perms.todolists.change_todolistpackage %} diff --git a/todolists/utils.py b/todolists/utils.py index e86d9054..51a75a3c 100644 --- a/todolists/utils.py +++ b/todolists/utils.py @@ -2,6 +2,7 @@ from django.db import connections, router from django.db.models import Count from .models import Todolist, TodolistPackage +from packages.models import Package def todo_counts(): @@ -36,4 +37,22 @@ def get_annotated_todolists(incomplete_only=False): return lists + +def attach_staging(packages, list_id): + '''Look for any staging version of the packages provided and attach them + to the 'staging' attribute on each package if found.''' + pkgnames = TodolistPackage.objects.filter( + todolist_id=list_id).values('pkgname') + staging_pkgs = Package.objects.normal().filter(repo__staging=True, + pkgname__in=pkgnames) + # now build a lookup dict to attach to the correct package + lookup = {(p.pkgname, p.arch): p for p in staging_pkgs} + + annotated = [] + for package in packages: + in_staging = lookup.get((package.pkgname, package.arch), None) + package.staging = in_staging + + return annotated + # vim: set ts=4 sw=4 et: diff --git a/todolists/views.py b/todolists/views.py index fcf62e23..f333728a 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -16,7 +16,7 @@ from main.models import Package, Repo from main.utils import find_unique_slug from packages.utils import attach_maintainers from .models import Todolist, TodolistPackage -from .utils import get_annotated_todolists +from .utils import get_annotated_todolists, attach_staging class TodoListForm(forms.ModelForm): @@ -69,6 +69,7 @@ def view(request, slug): # 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(todolist.packages()) + attach_staging(todolist.packages(), todolist.pk) arches = {tp.arch for tp in todolist.packages()} repos = {tp.repo for tp in todolist.packages()} return render(request, 'todolists/view.html', { |