From f17d7355e093b1fbe9f2d842b842dc0c6eaa35ed Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 5 Oct 2018 19:58:58 -0500 Subject: [PATCH] Auto-disable button when sending email preview --- tailbone/templates/settings/email/view.mako | 5 +++-- tailbone/views/email.py | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tailbone/templates/settings/email/view.mako b/tailbone/templates/settings/email/view.mako index 2e9f4325..fa3cb142 100644 --- a/tailbone/templates/settings/email/view.mako +++ b/tailbone/templates/settings/email/view.mako @@ -1,4 +1,4 @@ -## -*- coding: utf-8 -*- +## -*- coding: utf-8; -*- <%inherit file="/master/view.mako" /> <%def name="head_tags()"> @@ -21,8 +21,9 @@ ${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.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 TXT", '{}?key={}&type=txt'.format(url('email.preview'), instance['key']), id='preview-txt', class_='button', target='_blank')} or diff --git a/tailbone/views/email.py b/tailbone/views/email.py index f9a3516d..a2fd52cd 100644 --- a/tailbone/views/email.py +++ b/tailbone/views/email.py @@ -280,9 +280,7 @@ class EmailPreview(View): def email_template(self): recipient = self.request.POST.get('recipient') if recipient: - keys = [key for key in self.request.POST.keys() - if key.startswith('send_')] - key = keys[0][5:] if keys else None + key = self.request.POST.get('email_key') if key: email = mail.get_email(self.rattail_config, key) data = email.sample_data(self.request)