From 190bab9f4597ea30c408406b8bbef740d97b844b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= Date: Sun, 15 Feb 2015 13:53:52 -0600 Subject: [PATCH] rrs: Add support to display version by Milestone based on RecipeUpgrade's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aníbal Limón --- rrs/models.py | 10 ++++++++++ rrs/views.py | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/rrs/models.py b/rrs/models.py index 973d0b7..343f257 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -255,6 +255,16 @@ class RecipeUpgrade(models.Model): author_date = models.DateTimeField() commit_date = models.DateTimeField() + @staticmethod + def get_by_recipe_and_date(recipe, current_date): + rup_qry = RecipeUpgrade.objects.filter(recipe = recipe, + commit_date__lte = current_date).order_by('commit_date') + + if rup_qry: + return rup_qry[0] + else: + return None + def short_sha1(self): return self.sha1[0:6] diff --git a/rrs/views.py b/rrs/views.py index efbfaf9..a85b4fe 100644 --- a/rrs/views.py +++ b/rrs/views.py @@ -137,7 +137,13 @@ class RecipeListView(ListView): current_date <= milestone.end_date: version = recipe.pv else: - version = '' # Implement recipe version history + version = '' + + rup = RecipeUpgrade.get_by_recipe_and_date(recipe, + milestone.end_date) + + if not rup is None: + version = rup.version recipe_upstream = RecipeUpstream.get_by_recipe_and_history( recipe, recipe_upstream_history)