From a70c9d3360ab1dfbf014f851e672693e6ae53783 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 12 Aug 2016 01:17:40 -0500 Subject: [PATCH] Export 'enabled' flag for email profile/settings --- tailbone/views/email.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tailbone/views/email.py b/tailbone/views/email.py index 99de75bd..f5dbe7d2 100644 --- a/tailbone/views/email.py +++ b/tailbone/views/email.py @@ -91,6 +91,7 @@ class ProfilesView(MasterView): return ', '.join(recips) data = email.sample_data(self.request) return { + '_email': email, 'key': email.key, 'fallback_key': email.fallback_key, 'description': email.__doc__, @@ -101,6 +102,7 @@ class ProfilesView(MasterView): 'to': get_recips('to'), 'cc': get_recips('cc'), 'bcc': get_recips('bcc'), + 'enabled': email.get_enabled(), } def configure_grid(self, g): @@ -125,7 +127,7 @@ class ProfilesView(MasterView): return self.normalize(mail.get_email(self.rattail_config, key)) def get_instance_title(self, email): - return email['key'] + return email['_email'].get_complete_subject() def make_form(self, email, **kwargs): """ @@ -142,6 +144,7 @@ class ProfilesView(MasterView): fs.append(formalchemy.Field('to', value=email['to'], renderer=EmailListFieldRenderer, size='60x6')) fs.append(formalchemy.Field('cc', value=email['cc'], renderer=EmailListFieldRenderer, size='60x2')) fs.append(formalchemy.Field('bcc', value=email['bcc'], renderer=EmailListFieldRenderer, size='60x2')) + fs.append(formalchemy.Field('enabled', type=formalchemy.types.Boolean, value=email['enabled'])) form = forms.AlchemyForm(self.request, fs, creating=self.creating, @@ -163,6 +166,7 @@ class ProfilesView(MasterView): api.save_setting(Session(), 'rattail.mail.{}.to'.format(key), (fs.to._value or '').replace('\n', ', ')) api.save_setting(Session(), 'rattail.mail.{}.cc'.format(key), (fs.cc._value or '').replace('\n', ', ')) api.save_setting(Session(), 'rattail.mail.{}.bcc'.format(key), (fs.bcc._value or '').replace('\n', ', ')) + api.save_setting(Session(), 'rattail.mail.{}.enabled'.format(key), unicode(fs.enabled._value).lower()) def template_kwargs_view(self, **kwargs): key = self.request.matchdict['key']