diff options
authorDan McGee <>2011-02-18 16:35:54 -0600
committerDan McGee <>2011-02-19 00:32:26 -0600
commit3fb20c942da5afece6f8717a9c3bf878e18b508a (patch)
parenteb97b0400b7323540896b98ac0eddbd7b4373241 (diff)
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 <>
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/ b/packages/
index bc36f787..0afdee00 100644
--- a/packages/
+++ b/packages/
@@ -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: