summaryrefslogtreecommitdiff
path: root/packages/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-07-06 11:20:42 -0500
committerDan McGee <dan@archlinux.org>2011-07-06 11:27:33 -0500
commitba975112cbc36f7515293543baaacfbcb46a96c2 (patch)
treec705a13d953e137fe5bf6ffb13b83dad064e7de5 /packages/models.py
parent0f9a1da2cb9dd2a20a5e12bb346ec460b4335f9f (diff)
Add new packages signoff model
This one is centered around pkgbase, much as our PackageRelation object is. However, it also tracks all of the versioning fields we have in order to making joining against the current package testing list possible. Finally, additional metadata including a created date, an (optional) revoke date, and a comments field are added. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/models.py')
-rw-r--r--packages/models.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/packages/models.py b/packages/models.py
index faf5f398..55725e8e 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -32,12 +32,47 @@ class PackageRelation(models.Model):
return sorted(set([p.repo for p in packages]))
def __unicode__(self):
- return "%s: %s (%s)" % (
+ return u'%s: %s (%s)' % (
self.pkgbase, self.user, self.get_type_display())
class Meta:
unique_together = (('pkgbase', 'user', 'type'),)
+class Signoff(models.Model):
+ '''
+ A signoff for a package (by pkgbase) at a given point in time. These are
+ not keyed directly to a Package object so they don't ever get deleted when
+ Packages come and go from testing repositories.
+ '''
+ pkgbase = models.CharField(max_length=255, db_index=True)
+ pkgver = models.CharField(max_length=255)
+ pkgrel = models.CharField(max_length=255)
+ epoch = models.PositiveIntegerField(default=0)
+ arch = models.ForeignKey('main.Arch')
+ repo = models.ForeignKey('main.Repo')
+ user = models.ForeignKey(User, related_name="package_signoffs")
+ created = models.DateTimeField(editable=False)
+ revoked = models.DateTimeField(null=True)
+ comments = models.TextField(null=True, blank=True)
+
+ @property
+ def packages(self):
+ # TODO: delayed import to avoid circular reference
+ from main.models import Package
+ return Package.objects.normal().filter(pkgbase=self.pkgbase,
+ pkgver=self.pkgver, pkgrel=self.pkgrel, epoch=pkg.epoch,
+ arch=self.arch, repo=self.repo)
+
+ @property
+ def full_version(self):
+ if self.epoch > 0:
+ return u'%d:%s-%s' % (self.epoch, self.pkgver, self.pkgrel)
+ return u'%s-%s' % (self.pkgver, self.pkgrel)
+
+ def __unicode__(self):
+ return u'%s-%s: %s' % (
+ self.pkgbase, self.full_version, self.user)
+
class PackageGroup(models.Model):
'''
Represents a group a package is in. There is no actual group entity,
@@ -115,5 +150,7 @@ post_save.connect(remove_inactive_maintainers, sender=User,
dispatch_uid="packages.models")
pre_save.connect(set_created_field, sender=PackageRelation,
dispatch_uid="packages.models")
+pre_save.connect(set_created_field, sender=Signoff,
+ dispatch_uid="packages.models")
# vim: set ts=4 sw=4 et: