rattail-demo/rattail_demo/web/views/settings.py
2019-04-02 21:47:10 -05:00

39 lines
927 B
Python

# -*- 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
"""
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):
for pattern in self.protected:
if pattern.match(setting.name):
return False
return True
def deletable_instance(self, setting):
for pattern in self.protected:
if pattern.match(setting.name):
return False
return True
def includeme(config):
base.AppSettingsView.defaults(config)
SettingsView.defaults(config)