diff options
author | Dan McGee <dan@archlinux.org> | 2012-10-27 00:05:39 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-10-27 00:05:39 +0200 |
commit | 2ee662c77cf559d6ea82c9096533abfcd38f4801 (patch) | |
tree | c446017c1bae27f03b472d9812a0b5ab5b8d46f8 | |
parent | 0b97d52351fc2bdcae16f1a1e7c56afd4ed476ad (diff) | |
download | archweb-2ee662c77cf559d6ea82c9096533abfcd38f4801.tar.gz archweb-2ee662c77cf559d6ea82c9096533abfcd38f4801.tar.xz |
Extract some common architecture grabbing logic
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | packages/views/display.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/packages/views/display.py b/packages/views/display.py index b5cd643..efedf6f 100644 --- a/packages/views/display.py +++ b/packages/views/display.py @@ -13,11 +13,16 @@ from ..models import Update from ..utils import get_group_info, PackageJSONEncoder +def arch_plus_agnostic(arch): + arches = [ arch ] + arches.extend(Arch.objects.filter(agnostic=True).order_by()) + return arches + + def split_package_details(request, name, repo, arch): '''Check if we have a split package (e.g. pkgbase) value matching this name. If so, we can show a listing page for the entire set of packages.''' - arches = [ arch ] - arches.extend(Arch.objects.filter(agnostic=True)) + arches = arch_plus_agnostic(arch) pkgs = Package.objects.normal().filter(pkgbase=name, repo__testing=repo.testing, repo__staging=repo.staging, arch__in=arches).order_by('pkgname') @@ -42,8 +47,7 @@ def recently_removed_package(request, name, repo, arch, cutoff=CUTOFF): '''Check our packages update table to see if this package has existed in this repo before. If so, we can show a 410 Gone page and point the requester in the right direction.''' - arches = [ arch ] - arches.extend(Arch.objects.filter(agnostic=True)) + arches = arch_plus_agnostic(arch) match = Update.objects.select_related('arch', 'repo').filter( pkgname=name, repo=repo, arch__in=arches) if cutoff is not None: @@ -149,8 +153,7 @@ def groups(request, arch=None): def group_details(request, arch, name): arch = get_object_or_404(Arch, name=arch) - arches = [ arch ] - arches.extend(Arch.objects.filter(agnostic=True)) + arches = arch_plus_agnostic(arch) pkgs = Package.objects.normal().filter( groups__name=name, arch__in=arches).order_by('pkgname') if len(pkgs) == 0: |