rrs/models: add fields for more flexible email handling

* Add a flag to say whether emails should be sent
* Add fields for from/to/subject (to replace what's currently in
  settings)
* Add user link for administrator to replace the hardcoded values in the
  email template

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-03-02 08:31:01 +13:00
parent 0aa4b93d18
commit 735353ebd1
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('rrs', '0005_release_plan_nonnull'),
]
operations = [
migrations.AddField(
model_name='maintenanceplan',
name='admin',
field=models.ForeignKey(blank=True, null=True, help_text='Plan administrator', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='maintenanceplan',
name='email_enabled',
field=models.BooleanField(verbose_name='Enable emails', default=False, help_text='Enable automatically sending report emails for this plan'),
),
migrations.AddField(
model_name='maintenanceplan',
name='email_from',
field=models.CharField(max_length=255, blank=True, help_text='Sender for automated emails'),
),
migrations.AddField(
model_name='maintenanceplan',
name='email_subject',
field=models.CharField(max_length=255, blank=True, default='[Recipe reporting system] Upgradable recipe name list', help_text='Subject line of automated emails'),
),
migrations.AddField(
model_name='maintenanceplan',
name='email_to',
field=models.CharField(max_length=255, blank=True, help_text='Recipient for automated emails (separate multiple addresses with ;)'),
),
]

View File

@ -12,6 +12,7 @@ sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '../
from datetime import date from datetime import date
from django.db import models from django.db import models
from django.contrib.auth.models import User
from layerindex.models import Recipe, LayerBranch from layerindex.models import Recipe, LayerBranch
@ -19,6 +20,11 @@ class MaintenancePlan(models.Model):
name = models.CharField(max_length=50, unique=True) name = models.CharField(max_length=50, unique=True)
description = models.TextField(blank=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') updates_enabled = models.BooleanField('Enable updates', default=True, help_text='Enable automatically updating metadata for this plan via the update scripts')
email_enabled = models.BooleanField('Enable emails', default=False, help_text='Enable automatically sending report emails for this plan')
email_subject = models.CharField(max_length=255, blank=True, default='[Recipe reporting system] Upgradable recipe name list', help_text='Subject line of automated emails')
email_from = models.CharField(max_length=255, blank=True, help_text='Sender for automated emails')
email_to = models.CharField(max_length=255, blank=True, help_text='Recipient for automated emails (separate multiple addresses with ;)')
admin = models.ForeignKey(User, blank=True, null=True, help_text='Plan administrator')
def __str__(self): def __str__(self):
return '%s' % (self.name) return '%s' % (self.name)