diff --git a/rattail_demo/emails.py b/rattail_demo/emails.py index a60bf7b..b9c43c3 100644 --- a/rattail_demo/emails.py +++ b/rattail_demo/emails.py @@ -5,5 +5,14 @@ Email definitions 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) diff --git a/rattail_demo/web/views/email.py b/rattail_demo/web/views/email.py index 7c2d1ca..4343a5b 100644 --- a/rattail_demo/web/views/email.py +++ b/rattail_demo/web/views/email.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- """ Email views """ @@ -13,11 +13,17 @@ class ProfilesView(base.ProfilesView): Prevent edit/delete for 'feedback' email config """ + protected = [ + 'user_feedback', + 'upgrade_success', + 'upgrade_failure', + ] + def editable_instance(self, profile): - return profile['key'] != 'user_feedback' + return profile['key'] not in self.protected def deletable_instance(self, profile): - return profile['key'] != 'user_feedback' + return profile['key'] not in self.protected def includeme(config): diff --git a/rattail_demo/web/views/settings.py b/rattail_demo/web/views/settings.py index 9346227..42bf9b1 100644 --- a/rattail_demo/web/views/settings.py +++ b/rattail_demo/web/views/settings.py @@ -14,13 +14,23 @@ class SettingsView(base.SettingsView): """ 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): - 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): - 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):