summaryrefslogtreecommitdiff
path: root/packages/models.py
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2011-05-21 02:11:13 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2011-05-21 02:11:13 -0300
commita30350ac6e76c66d14f6d78ed2b5ae4e5799c79c (patch)
treea2b7127366a1b9d8d5be9fcda5abefacef7d2579 /packages/models.py
parentd8f82d9d72eec6042536797f75e06a9296f4cc71 (diff)
parent2470c543d60c96343a5b0fefe04464b5b445b859 (diff)
Merge branch 'master' of git://projects.archlinux.org/archweb
Conflicts: devel/views.py feeds.py templates/devel/index.html templates/packages/flag.html templates/public/index.html todolists/views.py urls.py
Diffstat (limited to 'packages/models.py')
-rw-r--r--packages/models.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/models.py b/packages/models.py
index 79e8abca..a950bddb 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -1,5 +1,7 @@
+from datetime import datetime
+
from django.db import models
-from django.db.models.signals import post_save
+from django.db.models.signals import pre_save, post_save
from django.contrib.auth.models import User
class PackageRelation(models.Model):
@@ -18,6 +20,7 @@ class PackageRelation(models.Model):
pkgbase = models.CharField(max_length=255)
user = models.ForeignKey(User, related_name="package_relations")
type = models.PositiveIntegerField(choices=TYPE_CHOICES, default=MAINTAINER)
+ created = models.DateTimeField(editable=False)
def get_associated_packages(self):
# TODO: delayed import to avoid circular reference
@@ -109,7 +112,15 @@ def remove_inactive_maintainers(sender, instance, created, **kwargs):
type=PackageRelation.MAINTAINER)
maint_relations.delete()
+def set_created_field(sender, **kwargs):
+ # We use this same callback for both Isos and Tests
+ obj = kwargs['instance']
+ if not obj.created:
+ obj.created = datetime.utcnow()
+
post_save.connect(remove_inactive_maintainers, sender=User,
dispatch_uid="packages.models")
+pre_save.connect(set_created_field, sender=PackageRelation,
+ dispatch_uid="packages.models")
# vim: set ts=4 sw=4 et: