Add overrides for email profiles, settings views

to make feedback email config readonly
This commit is contained in:
Lance Edgar 2016-12-10 14:55:36 -06:00
parent 365d5847a4
commit d812e5465a
4 changed files with 55 additions and 3 deletions

View file

@ -5,5 +5,5 @@ Email definitions
from __future__ import unicode_literals, absolute_import
# just tempmon emails for now
from rattail.emails import user_feedback
from rattail_tempmon.emails import tempmon_low_temp, tempmon_high_temp, tempmon_critical_temp, tempmon_error

View file

@ -33,14 +33,14 @@ def includeme(config):
config.include('tailbone.views.brands')
config.include('tailbone.views.customers')
config.include('tailbone.views.departments')
config.include('tailbone.views.email')
config.include('rattail_demo.web.views.email')
config.include('tailbone.views.employees')
config.include('tailbone.views.families')
config.include('rattail_demo.web.views.people')
config.include('tailbone.views.products')
config.include('tailbone.views.reportcodes')
config.include('tailbone.views.roles')
config.include('tailbone.views.settings')
config.include('rattail_demo.web.views.settings')
config.include('tailbone.views.stores')
config.include('tailbone.views.subdepartments')
config.include('rattail_demo.web.views.tempmon')

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
Email views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views import email as base
class ProfilesView(base.ProfilesView):
"""
Prevent edit/delete for 'feedback' email config
"""
def editable_instance(self, profile):
return profile['key'] != 'user_feedback'
def deletable_instance(self, profile):
return profile['key'] != 'user_feedback'
def includeme(config):
ProfilesView.defaults(config)
base.EmailPreview.defaults(config)

View file

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""
Settings views
"""
from __future__ import unicode_literals, absolute_import
import re
from tailbone.views import settings as base
class SettingsView(base.SettingsView):
"""
Prevent edit/delete for 'feedback' email settings
"""
feedback = re.compile(r'^rattail\.mail\.user_feedback\..*')
def editable_instance(self, setting):
return not bool(self.feedback.match(setting.name))
def deletable_instance(self, setting):
return not bool(self.feedback.match(setting.name))
def includeme(config):
SettingsView.defaults(config)