Auto-disable button when sending email preview

This commit is contained in:
Lance Edgar 2018-10-05 19:58:58 -05:00
parent 29e023096b
commit f17d7355e0
2 changed files with 4 additions and 5 deletions

View file

@ -1,4 +1,4 @@
## -*- coding: utf-8 -*- ## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" /> <%inherit file="/master/view.mako" />
<%def name="head_tags()"> <%def name="head_tags()">
@ -21,8 +21,9 @@
${parent.body()} ${parent.body()}
${h.form(url('email.preview'), name='send-email-preview')} ${h.form(url('email.preview'), name='send-email-preview', class_='autodisable')}
${h.csrf_token(request)} ${h.csrf_token(request)}
${h.hidden('email_key', value=instance['key'])}
${h.link_to("Preview HTML", '{}?key={}&type=html'.format(url('email.preview'), instance['key']), id='preview-html', class_='button', target='_blank')} ${h.link_to("Preview HTML", '{}?key={}&type=html'.format(url('email.preview'), instance['key']), id='preview-html', class_='button', target='_blank')}
${h.link_to("Preview TXT", '{}?key={}&type=txt'.format(url('email.preview'), instance['key']), id='preview-txt', class_='button', target='_blank')} ${h.link_to("Preview TXT", '{}?key={}&type=txt'.format(url('email.preview'), instance['key']), id='preview-txt', class_='button', target='_blank')}
or or

View file

@ -280,9 +280,7 @@ class EmailPreview(View):
def email_template(self): def email_template(self):
recipient = self.request.POST.get('recipient') recipient = self.request.POST.get('recipient')
if recipient: if recipient:
keys = [key for key in self.request.POST.keys() key = self.request.POST.get('email_key')
if key.startswith('send_')]
key = keys[0][5:] if keys else None
if key: if key:
email = mail.get_email(self.rattail_config, key) email = mail.get_email(self.rattail_config, key)
data = email.sample_data(self.request) data = email.sample_data(self.request)