From 1f49943aee6164ffd734fa1e46d38d2b3d635e31 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 27 Feb 2018 17:15:32 +1300 Subject: [PATCH] rrs: add maintenance plans The MaintenancePlan will provide some context for the RRS records so we can effectively enable RRS functionality only on certain layers where we want it. You can also consider the maintenance of multiple layers together under a single plan if desired. Here we add just the MaintenancePlan and the corresponding migration; a non-null link from the Release requires a separate migration and thus that will be done in a separate commit. Signed-off-by: Paul Eggleton --- rrs/admin.py | 14 ++++++++++- rrs/migrations/0002_maintenanceplan.py | 33 ++++++++++++++++++++++++++ rrs/models.py | 18 +++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 rrs/migrations/0002_maintenanceplan.py diff --git a/rrs/admin.py b/rrs/admin.py index cef0b8b..3f4178f 100644 --- a/rrs/admin.py +++ b/rrs/admin.py @@ -9,7 +9,18 @@ from django.contrib.admin import DateFieldListFilter from rrs.models import Release, Milestone, Maintainer, RecipeMaintainerHistory, \ RecipeMaintainer, RecipeDistro, RecipeUpgrade, RecipeUpstream, \ - RecipeUpstreamHistory + RecipeUpstreamHistory, MaintenancePlan, MaintenancePlanLayerBranch + +class MaintenancePlanLayerBranchInline(admin.StackedInline): + model = MaintenancePlanLayerBranch + min_num = 1 + extra = 0 + +class MaintenancePlanAdmin(admin.ModelAdmin): + model = MaintenancePlan + inlines = [ + MaintenancePlanLayerBranchInline, + ] class ReleaseAdmin(admin.ModelAdmin): search_fields = ['name'] @@ -58,6 +69,7 @@ class RecipeUpstreamAdmin(admin.ModelAdmin): 'type', ('date', DateFieldListFilter), 'history'] model = RecipeUpstream +admin.site.register(MaintenancePlan, MaintenancePlanAdmin) admin.site.register(Release, ReleaseAdmin) admin.site.register(Milestone, MilestoneAdmin) admin.site.register(Maintainer, MaintainerAdmin) diff --git a/rrs/migrations/0002_maintenanceplan.py b/rrs/migrations/0002_maintenanceplan.py new file mode 100644 index 0000000..b6718dc --- /dev/null +++ b/rrs/migrations/0002_maintenanceplan.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('layerindex', '0010_add_dependencies'), + ('rrs', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='MaintenancePlan', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('name', models.CharField(max_length=50, unique=True)), + ('description', models.TextField(blank=True)), + ('updates_enabled', models.BooleanField(verbose_name='Enable updates', default=True, help_text='Enable automatically updating metadata for this plan via the update scripts')), + ], + ), + migrations.CreateModel( + name='MaintenancePlanLayerBranch', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('layerbranch', models.ForeignKey(to='layerindex.LayerBranch')), + ('plan', models.ForeignKey(to='rrs.MaintenancePlan')), + ], + options={'verbose_name_plural': 'Maintenance plan layer branches'}, + ), + ] diff --git a/rrs/models.py b/rrs/models.py index 7c327fb..ebce4c3 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -12,7 +12,23 @@ sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '../ from datetime import date from django.db import models -from layerindex.models import Recipe +from layerindex.models import Recipe, LayerBranch + + +class MaintenancePlan(models.Model): + name = models.CharField(max_length=50, unique=True) + description = models.TextField(blank=True) + updates_enabled = models.BooleanField('Enable updates', default=True, help_text='Enable automatically updating metadata for this plan via the update scripts') + + def __str__(self): + return '%s' % (self.name) + +class MaintenancePlanLayerBranch(models.Model): + plan = models.ForeignKey(MaintenancePlan) + layerbranch = models.ForeignKey(LayerBranch) + + class Meta: + verbose_name_plural = "Maintenance plan layer branches" class Release(models.Model): name = models.CharField(max_length=100, unique=True)