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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-02-27 17:15:32 +13:00
parent 8a9a846d1e
commit 1f49943aee
3 changed files with 63 additions and 2 deletions

View File

@ -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)

View File

@ -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'},
),
]

View File

@ -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)