diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2015-01-28 17:38:04 -0600 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-05-04 23:57:51 +1200 |
commit | ac485c0cc4fcdfe9296ec6b1a913fa963c4f53f7 (patch) | |
tree | b571a0af1f6206b182e6c688070efb1da3b25c00 /rrs/models.py | |
parent | a1244395bb66e04f41733b2b61c4feda359e684b (diff) | |
download | openembedded-core-contrib-ac485c0cc4fcdfe9296ec6b1a913fa963c4f53f7.tar.gz |
rrs: Add support for Recipe maintainership history
Now can you get maintainers based on Milestones.
Feature changes,
rrs/models.py: Add RecipeMaintainerHistory to store maintainer updates.
rrs/admin.py: Add admin site for RecipeMaintainerHistory.
Adapt changes,
Now you need to specify RecipeMaintainerHistory to get RecipeMaintainer,
changes into rrs/view.py.
These set of changes are incompatible with the previous version you need
to do initial setup described in README.rrs.
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Diffstat (limited to 'rrs/models.py')
-rw-r--r-- | rrs/models.py | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/rrs/models.py b/rrs/models.py index abeaccbdbf..5c9bcc0b19 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -59,19 +59,67 @@ class Maintainer(models.Model): name = models.CharField(max_length=255, unique=True) email = models.CharField(max_length=255, blank=True) + """ + Create maintainer if no exist else update email. + Return Maintainer. + """ + @staticmethod + def create_or_update(name, email): + try: + m = Maintainer.objects.get(name = name) + m.email = email + except Maintainer.DoesNotExist: + m = Maintainer() + m.name = name + m.email = email + + m.save() + + return m + class Meta: ordering = ["name"] def __unicode__(self): return "%s <%s>" % (self.name, self.email) +class RecipeMaintainerHistory(models.Model): + title = models.CharField(max_length=255, blank=True) + date = models.DateTimeField() + author = models.ForeignKey(Maintainer) + sha1 = models.CharField(max_length=64, unique=True) + + @staticmethod + def get_last(): + rmh_qry = RecipeMaintainerHistory.objects.filter().order_by('-date') + + if rmh_qry: + return rmh_qry[0] + else: + return None + + @staticmethod + def get_by_end_date(end_date): + rmh_qry = RecipeMaintainerHistory.objects.filter( + date__lte = end_date).order_by('-date') + + if rmh_qry: + return rmh_qry[0] + else: + return RecipeMaintainerHistory.objects.filter().order_by('date')[0] + + def __unicode__(self): + return "%s: %s, %s" % (self.date, self.author.name, self.sha1[:10]) + class RecipeMaintainer(models.Model): recipe = models.ForeignKey(Recipe) - maintainer = models.ForeignKey(Maintainer) + maintainer = models.ForeignKey(Maintainer) + history = models.ForeignKey(RecipeMaintainerHistory) @staticmethod - def get_maintainer_by_recipe(recipe): - recipe_maintainer = RecipeMaintainer.objects.filter(recipe = recipe)[0] + def get_maintainer_by_recipe_and_history(recipe, history): + recipe_maintainer = RecipeMaintainer.objects.filter(recipe = recipe, + history = history)[0] return recipe_maintainer.maintainer def __unicode__(self): @@ -85,7 +133,7 @@ class RecipeUpstreamHistory(models.Model): @staticmethod def get_last_by_date_range(start, end): history = RecipeUpstreamHistory.objects.filter(start_date__gte = start, - start_date__lte = end).order_by('-id') + start_date__lte = end).order_by('-start_date') if history: return history[0] @@ -94,7 +142,7 @@ class RecipeUpstreamHistory(models.Model): @staticmethod def get_last(): - history = RecipeUpstreamHistory.objects.filter().order_by('-id') + history = RecipeUpstreamHistory.objects.filter().order_by('-start_date') if history: return history[0] @@ -121,7 +169,7 @@ class RecipeUpstream(models.Model): RECIPE_UPSTREAM_TYPE_CHOICES_DICT = dict(RECIPE_UPSTREAM_TYPE_CHOICES) recipe = models.ForeignKey(Recipe) - history = models.ForeignKey(RecipeUpstreamHistory, null=True) + history = models.ForeignKey(RecipeUpstreamHistory) version = models.CharField(max_length=100, blank=True) type = models.CharField(max_length=1, choices=RECIPE_UPSTREAM_TYPE_CHOICES, blank=True) status = models.CharField(max_length=1, choices=RECIPE_UPSTREAM_STATUS_CHOICES, blank=True) @@ -165,7 +213,7 @@ class RecipeDistro(models.Model): class RecipeUpgrade(models.Model): recipe = models.ForeignKey(Recipe) - maintainer = models.ForeignKey(Maintainer, blank=True, null=True) + maintainer = models.ForeignKey(Maintainer, blank=True) sha1 = models.CharField(max_length=40, blank=True) title = models.CharField(max_length=1024, blank=True) version = models.CharField(max_length=100, blank=True) |