Tweak email config views, to support subject "templates"

This commit is contained in:
Lance Edgar 2016-12-01 11:56:26 -06:00
parent cfd6e87cff
commit 083f8ecde0

View file

@ -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)