From 3faeab7d548552bfaa6719b75be9b6450b5031bd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 25 Jan 2014 09:16:48 -0600 Subject: Add 'Latest Update' column to stale package relations This helps when doing the irregular cleanup of these things and making sure a relation has been stale for some time and not just a couple minutes or hours. Signed-off-by: Dan McGee --- packages/models.py | 9 ++++++--- packages/utils.py | 3 ++- templates/packages/stale_relations.html | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/models.py b/packages/models.py index 6477d41..da8adc5 100644 --- a/packages/models.py +++ b/packages/models.py @@ -28,6 +28,9 @@ class PackageRelation(models.Model): type = models.PositiveIntegerField(choices=TYPE_CHOICES, default=MAINTAINER) created = models.DateTimeField(editable=False) + class Meta: + unique_together = (('pkgbase', 'user', 'type'),) + def get_associated_packages(self): return Package.objects.normal().filter(pkgbase=self.pkgbase) @@ -35,13 +38,13 @@ class PackageRelation(models.Model): packages = self.get_associated_packages() return sorted({p.repo for p in packages}) + def last_update(self): + return Update.objects.filter(pkgbase=self.pkgbase).latest() + def __unicode__(self): return u'%s: %s (%s)' % ( self.pkgbase, self.user, self.get_type_display()) - class Meta: - unique_together = (('pkgbase', 'user', 'type'),) - class SignoffSpecificationManager(models.Manager): def get_from_package(self, pkg): diff --git a/packages/utils.py b/packages/utils.py index 6ec3948..0f47f17 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -243,7 +243,8 @@ SELECT DISTINCT id cursor = connection.cursor() cursor.execute(sql, [PackageRelation.MAINTAINER]) to_fetch = [row[0] for row in cursor.fetchall()] - relations = PackageRelation.objects.select_related('user').filter( + relations = PackageRelation.objects.select_related( + 'user', 'user__userprofile').filter( id__in=to_fetch) return relations diff --git a/templates/packages/stale_relations.html b/templates/packages/stale_relations.html index 76f3205..f1ad437 100644 --- a/templates/packages/stale_relations.html +++ b/templates/packages/stale_relations.html @@ -52,6 +52,7 @@ User Type Created + Latest Update @@ -62,6 +63,7 @@ {{ relation.user.get_full_name }} {{ relation.get_type_display }} {{ relation.created }} + {{ relation.last_update.created }} {% empty %} No non-existent pkgbase relations. -- cgit v1.2.3-24-g4f1b