summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-04-09 17:37:56 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:53 +1200
commit560628c0e57197c5baa30180df43c6d8e882dbd7 (patch)
tree6d6d10670d50e3225ddfc2129a956ed6ac233b2c
parent34466bac1d008c03635db7b639d0939303c566f0 (diff)
downloadopenembedded-core-contrib-560628c0e57197c5baa30180df43c6d8e882dbd7.tar.gz
openembedded-core-contrib-560628c0e57197c5baa30180df43c6d8e882dbd7.tar.bz2
openembedded-core-contrib-560628c0e57197c5baa30180df43c6d8e882dbd7.zip
rrs: duplicate releases from first plan when adding a new plan
It's a pain to have to add all the releases when adding a new maintenance plan. Since these are likely to be the same (or similar) for every plan, then duplicate them across from the first plan when you save a new one. Also add "default" milestones on the assumption that other layers probably won't want to use the 4-milestone split per release, but there do have to be some milestone records, so just create one milestone for each release. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--rrs/admin.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/rrs/admin.py b/rrs/admin.py
index 07e09f4f4a..98cd0a02c8 100644
--- a/rrs/admin.py
+++ b/rrs/admin.py
@@ -53,6 +53,23 @@ class MaintenancePlanAdmin(admin.ModelAdmin):
inlines = [
MaintenancePlanLayerBranchInline,
]
+ def save_model(self, request, obj, form, change):
+ # For new maintenance plans, copy releases from the first plan
+ if obj.pk is None:
+ copyfrom_mp = MaintenancePlan.objects.all().first()
+ else:
+ copyfrom_mp = None
+ super().save_model(request, obj, form, change)
+ if copyfrom_mp:
+ for release in copyfrom_mp.release_set.all():
+ release.pk = None
+ release.plan = obj
+ release.save()
+ milestone = Milestone(release=release)
+ milestone.name='Default'
+ milestone.start_date = release.start_date
+ milestone.end_date = release.end_date
+ milestone.save()
class ReleaseAdmin(admin.ModelAdmin):
search_fields = ['name']