summaryrefslogtreecommitdiff
path: root/packages/models.py
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-11-14 22:02:39 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-11-14 22:02:39 -0500
commita2db6164a890d91307cbfed6794776f4f17c4955 (patch)
tree610deaae4780da796aa6b466c4b20868306926b8 /packages/models.py
parent4c22dbf07b12b172d9662c8d809fe0fb7b616a2f (diff)
parentd198137d718a5dfcaacedc3e2e3adf86c3192cd7 (diff)
Merge commit 'd198137' (update)
Diffstat (limited to 'packages/models.py')
-rw-r--r--packages/models.py45
1 files changed, 30 insertions, 15 deletions
diff --git a/packages/models.py b/packages/models.py
index 0d02ab31..77cade68 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -4,6 +4,7 @@ from django.db import models
from django.db.models.signals import pre_save, post_save
from django.contrib.auth.models import User
+from main.models import Arch, Repo
from main.utils import set_created_field
class PackageRelation(models.Model):
@@ -71,8 +72,8 @@ class SignoffSpecification(models.Model):
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')
+ arch = models.ForeignKey(Arch)
+ repo = models.ForeignKey(Repo)
user = models.ForeignKey(User, null=True)
created = models.DateTimeField(editable=False)
required = models.PositiveIntegerField(default=2,
@@ -134,8 +135,8 @@ class Signoff(models.Model):
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')
+ arch = models.ForeignKey(Arch)
+ repo = models.ForeignKey(Repo)
user = models.ForeignKey(User, related_name="package_signoffs")
created = models.DateTimeField(editable=False)
revoked = models.DateTimeField(null=True)
@@ -164,6 +165,29 @@ class Signoff(models.Model):
return u'%s-%s: %s%s' % (
self.pkgbase, self.full_version, self.user, revoked)
+
+class FlagRequest(models.Model):
+ user = models.ForeignKey(User, blank=True, null=True)
+ user_email = models.EmailField('email address')
+ created = models.DateTimeField(editable=False)
+ ip_address = models.IPAddressField('IP address')
+ pkgbase = models.CharField(max_length=255, db_index=True)
+ repo = models.ForeignKey(Repo)
+ num_packages = models.PositiveIntegerField('number of packages', default=1)
+ message = models.TextField('message to developer', blank=True)
+ is_spam = models.BooleanField(default=False,
+ help_text="Is this comment from a real person?")
+ is_legitimate = models.BooleanField(default=True,
+ help_text="Is this actually an out-of-date flag request?")
+
+ def who(self):
+ if self.user:
+ return self.user.get_full_name()
+ return self.user_email
+
+ def __unicode__(self):
+ return u'%s from %s on %s' % (self.pkgbase, self.who(), self.created)
+
class PackageGroup(models.Model):
'''
Represents a group a package is in. There is no actual group entity,
@@ -229,17 +253,8 @@ class Replacement(models.Model):
ordering = ['name']
-def remove_inactive_maintainers(sender, instance, created, **kwargs):
- # instance is an auth.models.User; we want to remove any existing
- # maintainer relations if the user is no longer active
- if not instance.is_active:
- maint_relations = PackageRelation.objects.filter(user=instance,
- type=PackageRelation.MAINTAINER)
- maint_relations.delete()
-
-post_save.connect(remove_inactive_maintainers, sender=User,
- dispatch_uid="packages.models")
-for sender in (PackageRelation, SignoffSpecification, Signoff):
+# hook up some signals
+for sender in (PackageRelation, SignoffSpecification, Signoff, FlagRequest):
pre_save.connect(set_created_field, sender=sender,
dispatch_uid="packages.models")