summaryrefslogtreecommitdiff
path: root/main/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'main/models.py')
-rw-r--r--main/models.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py
index 24aeed89..2f4d3520 100644
--- a/main/models.py
+++ b/main/models.py
@@ -193,14 +193,22 @@ class Package(models.Model):
category as this package if that check makes sense.
"""
from packages.models import Depend
+ sorttype = '''(CASE deptype
+ WHEN 'D' THEN 0
+ WHEN 'O' THEN 1
+ WHEN 'M' THEN 2
+ WHEN 'C' THEN 3
+ ELSE 1000 END)'''
name_clause = '''packages_depend.name IN (
SELECT %s UNION ALL
SELECT z.name FROM packages_provision z WHERE z.pkg_id = %s
)'''
requiredby = Depend.objects.select_related('pkg',
'pkg__arch', 'pkg__repo').extra(
- where=[name_clause], params=[self.pkgname, self.id]).order_by(
- 'pkg__pkgname', 'pkg__arch__name', 'pkg__repo__name')
+ select={'sorttype': sorttype},
+ where=[name_clause], params=[self.pkgname, self.id]).order_by(
+ 'sorttype', 'pkg__pkgname',
+ 'pkg__arch__name', 'pkg__repo__name')
if not self.arch.agnostic:
# make sure we match architectures if possible
requiredby = requiredby.filter(