source: rattail-demo/rattail_demo/web/views/settings.py @ e91858b

Last change on this file since e91858b was e91858b, checked in by Lance Edgar <lance@…>, 19 months ago

Add (protected) email settings for upgrade success, failure

  • Property mode set to 100644
File size: 884 bytes
Line 
1# -*- coding: utf-8 -*-
2"""
3Settings views
4"""
5
6from __future__ import unicode_literals, absolute_import
7
8import re
9
10from tailbone.views import settings as base
11
12
13class SettingsView(base.SettingsView):
14    """
15    Prevent edit/delete for 'feedback' email settings
16    """
17    protected = [
18        re.compile(r'^rattail\.mail\.user_feedback\..*'),
19        re.compile(r'^rattail\.mail\.upgrade_success\..*'),
20        re.compile(r'^rattail\.mail\.upgrade_failure\..*'),
21    ]
22
23    def editable_instance(self, setting):
24        for pattern in self.protected:
25            if pattern.match(setting.name):
26                return False
27        return True
28
29    def deletable_instance(self, setting):
30        for pattern in self.protected:
31            if pattern.match(setting.name):
32                return False
33        return True
34
35
36def includeme(config):
37    SettingsView.defaults(config)
Note: See TracBrowser for help on using the repository browser.