Allow adding broadcast templates

At the moment the page is the same as for text message templates,
except:
- different H1
- no guidance about personalisation, links, etc (until we decide how
  these should work)

For now you won’t be able to really create a broadcast template, because
the API doesn’t support it (the API will respond with a 400). But that’s
OK because no real services have the broadcast permission yet.

This required a bit of refactoring of how we check which template types
a service can use, because there were some hard-coded assumptions about
emails and text messages.
This commit is contained in:
Chris Hill-Scott
2020-07-01 16:43:08 +01:00
parent 8a1d86633c
commit 154d4bdb85
11 changed files with 175 additions and 77 deletions

View File

@@ -53,7 +53,6 @@ from app.template_previews import TemplatePreview, get_page_count_for_letter
from app.utils import (
PermanentRedirect,
Spreadsheet,
email_or_sms_not_enabled,
get_errors_for_csv,
get_help_argument,
get_template,
@@ -128,7 +127,7 @@ def send_messages(service_id, template_id):
elif db_template['template_type'] == 'sms':
sms_sender = get_sms_sender_from_session()
if email_or_sms_not_enabled(db_template['template_type'], current_service.permissions):
if db_template['template_type'] not in current_service.available_template_types:
return redirect(url_for(
'.action_blocked',
service_id=service_id,
@@ -302,8 +301,11 @@ def send_test(service_id, template_id):
db_template = current_service.get_template_with_user_permission_or_403(template_id, current_user)
if db_template['template_type'] == 'letter':
session['sender_id'] = None
return redirect(
url_for('.send_one_off_letter_address', service_id=service_id, template_id=template_id)
)
if email_or_sms_not_enabled(db_template['template_type'], current_service.permissions):
if db_template['template_type'] not in current_service.available_template_types:
return redirect(url_for(
'.action_blocked',
service_id=service_id,
@@ -311,11 +313,6 @@ def send_test(service_id, template_id):
return_to='view_template',
template_id=template_id))
if db_template['template_type'] == 'letter':
return redirect(
url_for('.send_one_off_letter_address', service_id=service_id, template_id=template_id)
)
return redirect(url_for(
{
'main.send_test': '.send_test_step',