From 0cc369e985dd6376f0367e4b57e980ce14231796 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 31 Jul 2012 00:09:28 -0500 Subject: Update several bits and pieces for staging packages This will prevent [staging] packages from cluttering normal user's view on the website, but allow us to still import everything from this repository for developer use. Signed-off-by: Dan McGee --- public/utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'public/utils.py') diff --git a/public/utils.py b/public/utils.py index a40c9b53..bf74881a 100644 --- a/public/utils.py +++ b/public/utils.py @@ -1,6 +1,6 @@ from operator import attrgetter -from main.models import Arch, Package +from main.models import Arch, Repo, Package from main.utils import cache_function, groupby_preserve_order, PackageStandin class RecentUpdate(object): @@ -50,7 +50,13 @@ def package_links(self): yield PackageStandin(package) @cache_function(62) -def get_recent_updates(number=15): +def get_recent_updates(number=15, testing=True, staging=False): + repos = Repo.objects.all() + if not testing: + repos = repos.exclude(testing=True) + if not staging: + repos = repos.exclude(staging=True) + # This is a bit of magic. We are going to show 15 on the front page, but we # want to try and eliminate cross-architecture wasted space. Pull enough # packages that we can later do some screening and trim out the fat. @@ -59,7 +65,7 @@ def get_recent_updates(number=15): fetch = number * 6 for arch in Arch.objects.all(): pkgs += list(Package.objects.normal().filter( - arch=arch).order_by('-last_update')[:fetch]) + arch=arch, repo__in=repos).order_by('-last_update')[:fetch]) pkgs.sort(key=attrgetter('last_update'), reverse=True) same_pkgbase_key = lambda x: (x.repo.name, x.pkgbase) -- cgit v1.2.3-54-g00ecf From 730ac948b5dfb70646fad96cd7bad0453b9f0cea Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 21 Dec 2012 19:11:47 -0600 Subject: Add a __unicode__ method for RecentUpdate Signed-off-by: Dan McGee --- public/utils.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'public/utils.py') diff --git a/public/utils.py b/public/utils.py index bf74881a..c2838212 100644 --- a/public/utils.py +++ b/public/utils.py @@ -49,6 +49,10 @@ def package_links(self): if package.arch not in arches and not arches.add(package.arch): yield PackageStandin(package) + def __unicode__(self): + return "RecentUpdate '%s %s' <%d packages>" % ( + self.pkgbase, self.version, len(self.packages)) + @cache_function(62) def get_recent_updates(number=15, testing=True, staging=False): repos = Repo.objects.all() -- cgit v1.2.3-54-g00ecf From f579f88e174abfd0514788879fd190035b6bbf87 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 11 Mar 2013 09:23:44 -0500 Subject: 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 --- public/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'public/utils.py') diff --git a/public/utils.py b/public/utils.py index c2838212..fcfd0f77 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 @@ def package_links(self): 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>" % ( -- cgit v1.2.3-54-g00ecf