summaryrefslogtreecommitdiff
path: root/packages/views
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-31 19:31:44 -0500
committerDan McGee <dan@archlinux.org>2012-07-31 19:31:44 -0500
commit5f85a1240da14e57760c2ba6585ae943d7a1d8c2 (patch)
treeb15a473edcc0db3f9cb3943ad9802e1ff1e8f692 /packages/views
parent5f410c000eaca4b5b25664f4dfb59cbe85ea034e (diff)
Reuse removed template for packages with multiple replacements
For example, bitcoin-git in the Arch repos is currently marked replaced by both bitcoin-qt and bitcoin-daemon. This allows us to show a page with both options listed instead of a blank 404 page. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views')
-rw-r--r--packages/views/display.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/packages/views/display.py b/packages/views/display.py
index d6922314..8adf3bee 100644
--- a/packages/views/display.py
+++ b/packages/views/display.py
@@ -50,12 +50,19 @@ def recently_removed_package(request, name, repo, arch, cutoff=CUTOFF):
when = now() - cutoff
match = match.filter(created__gte=when)
try:
- match = match.latest()
- elsewhere = match.elsewhere()
+ update = match.latest()
+ elsewhere = update.elsewhere()
if len(elsewhere) == 1:
return redirect(elsewhere[0])
- return render(request, 'packages/removed.html',
- {'update': match, }, status=410)
+ context = {
+ 'update': update,
+ 'elsewhere': elsewhere,
+ 'name': name,
+ 'version': update.old_version,
+ 'arch': arch,
+ 'repo': repo,
+ }
+ return render(request, 'packages/removed.html', context, status=410)
except Update.DoesNotExist:
return None
@@ -66,6 +73,15 @@ def replaced_package(request, name, repo, arch):
match = Package.objects.filter(replaces__name=name, repo=repo, arch=arch)
if len(match) == 1:
return redirect(match[0], permanent=True)
+ elif len(match) > 1:
+ context = {
+ 'elsewhere': match,
+ 'name': name,
+ 'version': '',
+ 'arch': arch,
+ 'repo': repo,
+ }
+ return render(request, 'packages/removed.html', context, status=410)
return None