summaryrefslogtreecommitdiff
path: root/packages/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/models.py')
-rw-r--r--packages/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/models.py b/packages/models.py
index 0afdee00..5dbdea45 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -19,6 +19,16 @@ class PackageRelation(models.Model):
user = models.ForeignKey(User, related_name="package_relations")
type = models.PositiveIntegerField(choices=TYPE_CHOICES, default=MAINTAINER)
+ def get_associated_packages(self):
+ # TODO: delayed import to avoid circular reference
+ from main.models import Package
+ return Package.objects.filter(pkgbase=self.pkgbase).select_related(
+ 'arch', 'repo')
+
+ def repositories(self):
+ packages = self.get_associated_packages()
+ return sorted(set([p.repo for p in packages]))
+
def __unicode__(self):
return "%s: %s (%s)" % (
self.pkgbase, self.user, self.get_type_display())