diff options
author | Dan McGee <dan@archlinux.org> | 2010-03-27 16:15:20 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-03-27 16:15:20 -0500 |
commit | fe832ea845f07a79b4580f7bca1dcf44b2f215ee (patch) | |
tree | cbe8554621f84d4f40b4991b883571ad5d419888 /main/models.py | |
parent | f3b3117d1f0ee8862a0b47d6dfe9b20960dbb13e (diff) |
Move package maintainer off of package model
This is an attempt to fix our long-standing problems dealing with maintainer
information. Move the actual maintainer information off of the package model
into a PackageRelation object, which has some flexibility to later represent
more than just maintainership.
This solves multiple problems:
* If a package gets accidentally deleted, so did the maintainer info
* Testing packages have always shown up as orphans
* With split packages, it was easy to miss some of the sub-packages
This commit does not include the deletion of the original maintainer column;
that will come at a later time when I feel more confident that the data was
migrated correctly.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/models.py')
-rw-r--r-- | main/models.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/main/models.py b/main/models.py index 0954f79d..b49acd2c 100644 --- a/main/models.py +++ b/main/models.py @@ -1,7 +1,9 @@ from django.db import models from django.db.models import Q from django.contrib.auth.models import User + from main.middleware import get_user +from packages.models import PackageRelation ########################### ### User Profile Class #### @@ -203,6 +205,18 @@ class Package(models.Model): self.arch.name, self.pkgname) @property + def pkgbase_safe(self): + if self.pkgbase: + return self.pkgbase + return self.pkgname + + @property + def maintainers(self): + return User.objects.filter( + package_relations__pkgbase=self.pkgbase_safe, + package_relations__type=PackageRelation.MAINTAINER) + + @property def signoffs(self): if 'signoffs_cache' in dir(self): if len(self.signoffs_cache) > 0: @@ -265,16 +279,12 @@ class Package(models.Model): def get_svn_link(self, svnpath): linkbase = "http://repos.archlinux.org/wsvn/%s/%s/%s/" - if self.pkgbase: - dirname = self.pkgbase - else: - dirname = self.pkgname repo = self.repo.name.lower() if repo.startswith('community'): root = 'community' else: root = 'packages' - return linkbase % (root, dirname, svnpath) + return linkbase % (root, self.pkgbase_safe, svnpath) def get_arch_svn_link(self): repo = self.repo.name.lower() @@ -362,4 +372,3 @@ class ExternalProject(models.Model): return self.name # vim: set ts=4 sw=4 et: - |