summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-12-12 04:19:16 +0100
committerDan McGee <dan@archlinux.org>2012-12-12 04:20:07 +0100
commite08096ee214b1fd60d093e2902c6acec9cf4ae5f (patch)
tree2d260f5d4b972c4b300ccf147843910e4d1bc7b4 /packages
parent040e0ddea591702856ce7d737bf4ea31f60a89e5 (diff)
downloadarchweb-e08096ee214b1fd60d093e2902c6acec9cf4ae5f.tar.gz
archweb-e08096ee214b1fd60d093e2902c6acec9cf4ae5f.tar.xz
Fix FS#32018, provides links always go to [testing] packages
Remove some of the smarts and do less, but be better about properly sorting the items as one might expect. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r--packages/models.py24
1 files changed, 6 insertions, 18 deletions
diff --git a/packages/models.py b/packages/models.py
index ede8c27..a4095f5 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -412,24 +412,12 @@ class RelatedToBase(models.Model):
new_pkgs.append(package)
pkgs = new_pkgs
- # Logic here is to filter out packages that are in multiple repos if
- # they are not requested. For example, if testing is False, only show a
- # testing package if it doesn't exist in a non-testing repo.
- filtered = {}
- for package in pkgs:
- if package.pkgname not in filtered or \
- package.repo.staging == self.pkg.repo.staging:
- filtered[package.pkgname] = package
- pkgs = filtered.values()
-
- filtered = {}
- for package in pkgs:
- if package.pkgname not in filtered or \
- package.repo.testing == self.pkg.repo.testing:
- filtered[package.pkgname] = package
- pkgs = filtered.values()
-
- return pkgs
+ # Sort providers by preference. We sort those in same staging/testing
+ # combination first, followed by others. We sort by a (staging,
+ # testing) match tuple that will be (True, True) in the best case.
+ key_func = lambda x: (x.repo.staging == self.pkg.repo.staging,
+ x.repo.testing == self.pkg.repo.testing)
+ return sorted(pkgs, key=key_func, reverse=True)
def __unicode__(self):
if self.version: