summaryrefslogtreecommitdiff
path: root/packages/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-03-27 16:15:20 -0500
committerDan McGee <dan@archlinux.org>2010-03-27 16:15:20 -0500
commitfe832ea845f07a79b4580f7bca1dcf44b2f215ee (patch)
treecbe8554621f84d4f40b4991b883571ad5d419888 /packages/models.py
parentf3b3117d1f0ee8862a0b47d6dfe9b20960dbb13e (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 'packages/models.py')
-rw-r--r--packages/models.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/models.py b/packages/models.py
new file mode 100644
index 00000000..9eff5177
--- /dev/null
+++ b/packages/models.py
@@ -0,0 +1,23 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+class PackageRelation(models.Model):
+ '''
+ Represents maintainership (or interest) in a package by a given developer.
+ It is not a true foreign key to packages as we want to key off
+ pkgbase/pkgname instead, as well as preserve this information across
+ package deletes, adds, and in all repositories.
+ '''
+ MAINTAINER = 1
+ WATCHER = 2
+ TYPE_CHOICES = (
+ (MAINTAINER, 'Maintainer'),
+ (WATCHER, 'Watcher'),
+ )
+ pkgbase = models.CharField(max_length=255)
+ user = models.ForeignKey(User, related_name="package_relations")
+ type = models.PositiveIntegerField(choices=TYPE_CHOICES, default=MAINTAINER)
+ class Meta:
+ unique_together = (('pkgbase', 'user', 'type'),)
+
+# vim: set ts=4 sw=4 et: