From 083f8ecde06b0a5f90d615a467785711cb975cbf Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 1 Dec 2016 11:56:26 -0600 Subject: [PATCH] Tweak email config views, to support subject "templates" --- tailbone/views/email.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tailbone/views/email.py b/tailbone/views/email.py index bb6a2b14..9479bb6f 100644 --- a/tailbone/views/email.py +++ b/tailbone/views/email.py @@ -96,7 +96,7 @@ class ProfilesView(MasterView): 'fallback_key': email.fallback_key, 'description': email.__doc__, 'prefix': email.get_prefix(data), - 'subject': email.get_subject(data), + 'subject': email.get_subject(data, render=False), 'sender': email.get_sender(), 'replyto': email.get_replyto(), 'to': get_recips('to'), @@ -127,7 +127,7 @@ class ProfilesView(MasterView): return self.normalize(mail.get_email(self.rattail_config, key)) def get_instance_title(self, email): - return email['_email'].get_complete_subject() + return email['_email'].get_complete_subject(render=False) def make_form(self, email, **kwargs): """ @@ -228,11 +228,18 @@ class EmailPreview(View): self.request.response.content_type = b'text/plain' return self.request.response + @classmethod + def defaults(cls, config): + # email preview + config.add_route('email.preview', '/email/preview/') + config.add_view(cls, route_name='email.preview', + renderer='/email/preview.mako', + permission='emailprofiles.preview') + config.add_tailbone_permission('emailprofiles', 'emailprofiles.preview', + "Send preview email") + + def includeme(config): ProfilesView.defaults(config) - - config.add_route('email.preview', '/email/preview/') - config.add_view(EmailPreview, route_name='email.preview', - renderer='/email/preview.mako', - permission='admin') + EmailPreview.defaults(config)