summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-18 23:35:54 +0100
committerDan McGee <dan@archlinux.org>2011-02-19 07:32:26 +0100
commit3fb20c942da5afece6f8717a9c3bf878e18b508a (patch)
tree19727b91ba0d3028c16104f71bf6fc7d46a27baa
parenteb97b0400b7323540896b98ac0eddbd7b4373241 (diff)
downloadarchweb-3fb20c942da5afece6f8717a9c3bf878e18b508a.tar.gz
archweb-3fb20c942da5afece6f8717a9c3bf878e18b508a.tar.xz
Remove maintainer relations if user marked inactive
These users are being marked inactive because they are no longer developers; thus they should have all of their maintainer relations removed from the database. This is one of two causes of "orphan" package relation objects, the other being pkgbase values that go out of existence. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/models.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/models.py b/packages/models.py
index bc36f78..0afdee0 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -1,4 +1,5 @@
from django.db import models
+from django.db.models.signals import post_save
from django.contrib.auth.models import User
class PackageRelation(models.Model):
@@ -46,4 +47,15 @@ class License(models.Model):
class Meta:
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")
+
# vim: set ts=4 sw=4 et: