summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-03-11 15:23:44 +0100
committerDan McGee <dan@archlinux.org>2013-03-11 15:40:38 +0100
commitf579f88e174abfd0514788879fd190035b6bbf87 (patch)
treec8623c9b6e0e9b666878d80c81c7ae15f85569e3 /public
parent7bf9c6e065731b414e3c1733db3b0de9105259fe (diff)
downloadarchweb-f579f88e174abfd0514788879fd190035b6bbf87.tar.gz
archweb-f579f88e174abfd0514788879fd190035b6bbf87.tar.xz
Don't link to a one-element listing page from recent updates
If a package is built as a split package where pkgname != pkgbase, but only one actual split package is produced, the link on the recent update screen requires an extra click to get to the single package. Fix this by linking directly to the package itself. (Examples in current repos: ntfs-3g, python2-south) Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'public')
-rw-r--r--public/utils.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/public/utils.py b/public/utils.py
index c283821..fcfd0f7 100644
--- a/public/utils.py
+++ b/public/utils.py
@@ -1,3 +1,4 @@
+from collections import defaultdict
from operator import attrgetter
from main.models import Arch, Repo, Package
@@ -44,10 +45,14 @@ class RecentUpdate(object):
else:
# fake out the template- this is slightly hacky but yields one
# 'package-like' object per arch which is what the normal loop does
- arches = set()
+ by_arch = defaultdict(list)
for package in self.others:
- if package.arch not in arches and not arches.add(package.arch):
- yield PackageStandin(package)
+ by_arch[package.arch].append(package)
+ for arch, packages in by_arch.items():
+ if len(packages) == 1:
+ yield packages[0]
+ else:
+ yield PackageStandin(packages[0])
def __unicode__(self):
return "RecentUpdate '%s %s' <%d packages>" % (