diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-15 00:34:16 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-15 00:34:16 -0500 |
commit | a9117384bf194929713198504a099d7e687b60a7 (patch) | |
tree | 59366b53c21ce666f2bcf1f29b779c007bb36027 /packages | |
parent | 5a44fadffe77e0c2bda0e57916ab573e547f9bf8 (diff) | |
parent | 1f18484cae88e5553caa5fd593ef31ad458adb25 (diff) |
Merge commit '1f18484' (update)
Diffstat (limited to 'packages')
-rw-r--r-- | packages/views/__init__.py | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/packages/views/__init__.py b/packages/views/__init__.py index e66da179..9ca21407 100644 --- a/packages/views/__init__.py +++ b/packages/views/__init__.py @@ -103,6 +103,28 @@ def update(request): messages.error(request, "Are you trying to adopt or disown?") return redirect('/packages/') +def split_package_details(request, name='', repo='', arch=''): + arch = get_object_or_404(Arch, name=arch) + arches = [ arch ] + arches.extend(Arch.objects.filter(agnostic=True)) + repo = get_object_or_404(Repo, name__iexact=repo) + pkgs = Package.objects.normal().filter(pkgbase=name, + repo__testing=repo.testing, repo__staging=repo.staging, + arch__in=arches).order_by('pkgname') + if len(pkgs) == 0: + raise Http404 + # we have packages, but ensure at least one is in the given repo + if not any(True for pkg in pkgs if pkg.repo == repo): + raise Http404 + context = { + 'list_title': 'Split Package Details', + 'name': name, + 'arch': arch, + 'packages': pkgs, + } + return direct_to_template(request, 'packages/packages_list.html', + context) + def details(request, name='', repo='', arch=''): if all([name, repo, arch]): try: @@ -112,23 +134,7 @@ def details(request, name='', repo='', arch=''): return direct_to_template(request, 'packages/details.html', {'pkg': pkg, }) except Package.DoesNotExist: - arch = get_object_or_404(Arch, name=arch) - arches = [ arch ] - arches.extend(Arch.objects.filter(agnostic=True)) - repo = get_object_or_404(Repo, name__iexact=repo) - pkgs = Package.objects.normal().filter(pkgbase=name, - repo__testing=repo.testing, repo__staging=repo.staging, - arch__in=arches).order_by('pkgname') - if len(pkgs) == 0: - raise Http404 - context = { - 'list_title': 'Split Package Details', - 'name': name, - 'arch': arch, - 'packages': pkgs, - } - return direct_to_template(request, 'packages/packages_list.html', - context) + return split_package_details(request, name, repo, arch) else: pkg_data = [ ('arch', arch.lower()), |