Add (protected) email settings for upgrade success, failure

This commit is contained in:
Lance Edgar 2018-08-17 13:08:48 -05:00
parent 12c8b3b8dd
commit e91858b567
3 changed files with 33 additions and 8 deletions

View file

@ -5,5 +5,14 @@ Email definitions
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
from rattail.emails import user_feedback
from rattail_tempmon.emails import tempmon_low_temp, tempmon_high_temp, tempmon_critical_temp, tempmon_error # bring in some common config from rattail
from rattail.emails import (upgrade_failure,
upgrade_success,
user_feedback)
# bring in some common config from rattail_tempmon
from rattail.emails import (tempmon_low_temp,
tempmon_high_temp,
tempmon_critical_temp,
tempmon_error)

View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
""" """
Email views Email views
""" """
@ -13,11 +13,17 @@ class ProfilesView(base.ProfilesView):
Prevent edit/delete for 'feedback' email config Prevent edit/delete for 'feedback' email config
""" """
protected = [
'user_feedback',
'upgrade_success',
'upgrade_failure',
]
def editable_instance(self, profile): def editable_instance(self, profile):
return profile['key'] != 'user_feedback' return profile['key'] not in self.protected
def deletable_instance(self, profile): def deletable_instance(self, profile):
return profile['key'] != 'user_feedback' return profile['key'] not in self.protected
def includeme(config): def includeme(config):

View file

@ -14,13 +14,23 @@ class SettingsView(base.SettingsView):
""" """
Prevent edit/delete for 'feedback' email settings Prevent edit/delete for 'feedback' email settings
""" """
feedback = re.compile(r'^rattail\.mail\.user_feedback\..*') protected = [
re.compile(r'^rattail\.mail\.user_feedback\..*'),
re.compile(r'^rattail\.mail\.upgrade_success\..*'),
re.compile(r'^rattail\.mail\.upgrade_failure\..*'),
]
def editable_instance(self, setting): def editable_instance(self, setting):
return not bool(self.feedback.match(setting.name)) for pattern in self.protected:
if pattern.match(setting.name):
return False
return True
def deletable_instance(self, setting): def deletable_instance(self, setting):
return not bool(self.feedback.match(setting.name)) for pattern in self.protected:
if pattern.match(setting.name):
return False
return True
def includeme(config): def includeme(config):