summaryrefslogtreecommitdiffstats
path: root/packages/views
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-23 17:18:59 +0100
committerDan McGee <dan@archlinux.org>2013-01-23 17:18:59 +0100
commita10798b756bbfc5d8dbad76546ca670efca75e56 (patch)
treed378a3a5140501b46e0e99c8398b12ca78145dc8 /packages/views
parentbe49f26a815cca589c625ff8dd99c85a80262281 (diff)
downloadarchweb-a10798b756bbfc5d8dbad76546ca670efca75e56.tar.gz
archweb-a10798b756bbfc5d8dbad76546ca670efca75e56.tar.xz
Use querysets for calls to get_object_or_404(Package)
This works better in most cases since we need the architecture and repository objects at some point during the view process. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views')
-rw-r--r--packages/views/display.py8
-rw-r--r--packages/views/flag.py6
2 files changed, 7 insertions, 7 deletions
diff --git a/packages/views/display.py b/packages/views/display.py
index 445c1ab..c2369ab 100644
--- a/packages/views/display.py
+++ b/packages/views/display.py
@@ -168,7 +168,7 @@ def group_details(request, arch, name):
def files(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
# files are inserted in sorted order, so preserve that
fileslist = PackageFile.objects.filter(pkg=pkg).order_by('id')
@@ -185,14 +185,14 @@ def files(request, name, repo, arch):
def details_json(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
to_json = json.dumps(pkg, ensure_ascii=False, cls=PackageJSONEncoder)
return HttpResponse(to_json, content_type='application/json')
def files_json(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
# files are inserted in sorted order, so preserve that
fileslist = PackageFile.objects.filter(pkg=pkg).order_by('id')
@@ -213,7 +213,7 @@ def files_json(request, name, repo, arch):
def download(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
url = get_mirror_url_for_download()
if not url:
diff --git a/packages/views/flag.py b/packages/views/flag.py
index dadadd1..edb3f09 100644
--- a/packages/views/flag.py
+++ b/packages/views/flag.py
@@ -49,7 +49,7 @@ def flaghelp(request):
@never_cache
def flag(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
if pkg.flag_date is not None:
# already flagged. do nothing.
@@ -158,7 +158,7 @@ def flag_confirmed(request, name, repo, arch):
@permission_required('main.change_package')
def unflag(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
pkg.flag_date = None
pkg.save()
@@ -166,7 +166,7 @@ def unflag(request, name, repo, arch):
@permission_required('main.change_package')
def unflag_all(request, name, repo, arch):
- pkg = get_object_or_404(Package,
+ pkg = get_object_or_404(Package.objects.normal(),
pkgname=name, repo__name__iexact=repo, arch__name=arch)
# find all packages from (hopefully) the same PKGBUILD
pkgs = Package.objects.filter(pkgbase=pkg.pkgbase,