summaryrefslogtreecommitdiffstats
path: root/todolists/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-22 23:47:43 +0100
committerDan McGee <dan@archlinux.org>2013-01-22 23:47:43 +0100
commite9e1c071654edd7b95e20c8105abbc23f426cecc (patch)
tree3becfd32ef3535d15504d98fff68969787634a0e /todolists/utils.py
parent53484c45ea82a5afa8bf167f978f657b866d4c93 (diff)
downloadarchweb-e9e1c071654edd7b95e20c8105abbc23f426cecc.tar.gz
archweb-e9e1c071654edd7b95e20c8105abbc23f426cecc.tar.xz
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>
Diffstat (limited to 'todolists/utils.py')
-rw-r--r--todolists/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/todolists/utils.py b/todolists/utils.py
index e86d905..51a75a3 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: