Show replacments for package if it has been removed

This covers the case where we can't find the package in any other
repositories, but it was removed recently enough that we have a found
package update object.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2013-04-13 13:05:02 -05:00
parent f2a6316be0
commit 7fc8da7d95
2 changed files with 11 additions and 0 deletions

View File

@ -321,6 +321,15 @@ def elsewhere(self):
return Package.objects.normal().filter(
pkgname=self.pkgname, arch=self.arch)
def replacements(self):
pkgs = Package.objects.normal().filter(
replaces__name=self.pkgname)
if not self.arch.agnostic:
# make sure we match architectures if possible
arches = self.pkg.applicable_arches()
pkgs = pkgs.filter(arch__in=arches)
return pkgs
def __unicode__(self):
return u'%s of %s on %s' % (self.get_action_flag_display(),
self.pkgname, self.created)

View File

@ -55,6 +55,8 @@ def recently_removed_package(request, name, repo, arch, cutoff=CUTOFF):
try:
update = match.latest()
elsewhere = update.elsewhere()
if len(elsewhere) == 0:
elsewhere = update.replacements()
if len(elsewhere) == 1:
return redirect(elsewhere[0])
context = {