Export 'enabled' flag for email profile/settings

This commit is contained in:
Lance Edgar 2016-08-12 01:17:40 -05:00
parent 457407fbcf
commit a70c9d3360

View file

@ -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']