aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-09 16:36:13 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit1f037470fb999f6799c2db1774bc00b4a205c17f (patch)
treef062c4dad3b1e6fd093dc7e9706013524458ca80
parent183ba0f7eb3024cd8072689736ae8ca7fb5f9477 (diff)
downloadopenembedded-core-contrib-1f037470fb999f6799c2db1774bc00b4a205c17f.tar.gz
openembedded-core-contrib-1f037470fb999f6799c2db1774bc00b4a205c17f.tar.bz2
openembedded-core-contrib-1f037470fb999f6799c2db1774bc00b4a205c17f.zip
rrs: releases should be unique by plan and name, not just name
I missed changing this constraint when adding the plan field. We want to be able to have the same named release on another plan. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--rrs/migrations/0011_release_name_unique.py23
-rw-r--r--rrs/models.py14
2 files changed, 34 insertions, 3 deletions
diff --git a/rrs/migrations/0011_release_name_unique.py b/rrs/migrations/0011_release_name_unique.py
new file mode 100644
index 00000000000..0c2442df084
--- /dev/null
+++ b/rrs/migrations/0011_release_name_unique.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0010_recipemaintenancelink'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='release',
+ name='name',
+ field=models.CharField(max_length=100),
+ ),
+ migrations.AlterUniqueTogether(
+ name='release',
+ unique_together=set([('plan', 'name')]),
+ ),
+ ]
diff --git a/rrs/models.py b/rrs/models.py
index 635193cf545..5f70258045b 100644
--- a/rrs/models.py
+++ b/rrs/models.py
@@ -47,10 +47,13 @@ class MaintenancePlanLayerBranch(models.Model):
class Release(models.Model):
plan = models.ForeignKey(MaintenancePlan)
- name = models.CharField(max_length=100, unique=True)
+ name = models.CharField(max_length=100)
start_date = models.DateField(db_index=True)
end_date = models.DateField(db_index=True)
+ class Meta:
+ unique_together = ('plan', 'name',)
+
def get_default_milestone(self):
return self.milestone_set.last()
@@ -69,8 +72,13 @@ class Release(models.Model):
def get_current(maintplan):
current = date.today()
current_release = Release.get_by_date(maintplan, current)
-
- return current_release or Release.objects.filter(plan=maintplan).order_by('-end_date')[0]
+ if current_release:
+ return current_release
+ else:
+ plan_releases = Release.objects.filter(plan=maintplan).order_by('-end_date')
+ if plan_releases:
+ return plan_releases[0]
+ return None
def __str__(self):
return '%s' % (self.name)