From 4a71835d07a716d6f910a2e652072af9e25bdfc9 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Sun, 21 Apr 2019 16:53:42 +0200 Subject: main: Handle multiple testing repositories Since there are multiple [testing] repositories when a package is in kde-unstable, testing and flagged in extra the in_testing function will generate an error since there are multiple results. Rewrite the query so it handles multiple results and order it by id since [testing] should have a lower id then kde-unstable. --- main/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/models.py b/main/models.py index e23a47a8..c033a079 100644 --- a/main/models.py +++ b/main/models.py @@ -397,8 +397,9 @@ class Package(models.Model): if self.repo.testing: return None try: - return Package.objects.normal().get(repo__testing=True, - pkgname=self.pkgname, arch=self.arch) + # Kde-unstable is also a [testing] repo so sort on id. + return Package.objects.filter(repo__testing=True, + pkgname=self.pkgname, arch=self.arch).order_by('-id').first() except Package.DoesNotExist: return None -- cgit v1.2.3-55-g3dc8