RRS: ensure default URLs for release/milestone are the latest

In the "Maintenance Plan" drop-down the maintenance plans point to the
"default" release and milestone, but it was picking the most recently
added record in the database rather than the latest one by date. Use an
order_by() to ensure we get the most recent release/milestone by date
rather than just the most recently added in case they have been added
out-of-order.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2019-10-23 09:37:50 +13:00
parent 869ebec108
commit 9cdd341cfd

View File

@ -33,7 +33,7 @@ class MaintenancePlan(models.Model):
maintainer_style = models.CharField(max_length=1, choices=MAINTENANCEPLAN_MAINTAINER_STYLE, default='L', help_text='Maintainer tracking style for the layers within this plan') maintainer_style = models.CharField(max_length=1, choices=MAINTENANCEPLAN_MAINTAINER_STYLE, default='L', help_text='Maintainer tracking style for the layers within this plan')
def get_default_release(self): def get_default_release(self):
return self.release_set.filter(milestone__isnull=False).last() return self.release_set.filter(milestone__isnull=False).order_by('-start_date').first()
def per_recipe_maintainers(self): def per_recipe_maintainers(self):
return self.maintainer_style != 'L' return self.maintainer_style != 'L'
@ -63,7 +63,7 @@ class Release(models.Model):
unique_together = ('plan', 'name',) unique_together = ('plan', 'name',)
def get_default_milestone(self): def get_default_milestone(self):
return self.milestone_set.last() return self.milestone_set.order_by('-start_date').first()
@staticmethod @staticmethod
def get_by_date(maintplan, date): def get_by_date(maintplan, date):