summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDusty Phillips <buchuki@gmail.com>2008-10-10 18:16:40 -0400
committerDusty Phillips <buchuki@gmail.com>2008-10-10 18:16:40 -0400
commit5deece773c4083de6e2769c2ea7976412e40d206 (patch)
treefc846f6c18e79600759e37940e08fbd93d96c32f
parent5e68129b0f30e45f03e5970526d02df40279466b (diff)
replace an ugly query with a nice query
-rw-r--r--main/models.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/main/models.py b/main/models.py
index a2323c62..9f382cb0 100644
--- a/main/models.py
+++ b/main/models.py
@@ -189,16 +189,10 @@ class Package(models.Model):
"""
Returns a list of package objects.
"""
- reqs = []
- requiredby = PackageDepend.objects.filter(depname=self.pkgname).filter(
- Q(pkg__arch=self.arch) | Q(pkg__arch__name__iexact='any'))
- for req in requiredby:
- reqs.append(req.pkg)
- ## sort the resultant list. Django has problems in the orm with
- ## trying to shoehorn the sorting into the reverse foreign key
- ## reference in the query above. :(
- reqs.sort(lambda a,b: cmp(a.pkgname,b.pkgname))
- return reqs
+ requiredby = Package.objects.filter(
+ packagedepend__depname=self.pkgname,
+ arch__name__in=(self.arch.name, 'Any'))
+ return requiredby.order_by('pkgname')
def get_depends(self):
"""