mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 06:38:24 -04:00
Sprinkle letter throughout the app
Let users create/edit/delete letter templates. Let them upload a CSV file or send a test against a letter template. Big assumption at the moment is that addresses only have one line, and therefore one column in the CSV file.
This commit is contained in:
@@ -33,7 +33,8 @@ from app.utils import user_has_permissions, get_errors_for_csv, Spreadsheet, get
|
||||
def get_page_headings(template_type):
|
||||
return {
|
||||
'email': 'Email templates',
|
||||
'sms': 'Text message templates'
|
||||
'sms': 'Text message templates',
|
||||
'letter': 'Letter templates'
|
||||
}[template_type]
|
||||
|
||||
|
||||
@@ -52,7 +53,8 @@ def get_example_csv_rows(template, use_example_as_example=True, submitted_fields
|
||||
'email': 'test@example.com' if use_example_as_example else current_user.email_address,
|
||||
'sms': '07700 900321' if use_example_as_example else validate_and_format_phone_number(
|
||||
current_user.mobile_number, human_readable=True
|
||||
)
|
||||
),
|
||||
'letter': current_user.name
|
||||
}[template.template_type]
|
||||
] + get_example_csv_fields(template.placeholders, use_example_as_example, submitted_fields)
|
||||
|
||||
@@ -66,8 +68,10 @@ def get_example_csv_rows(template, use_example_as_example=True, submitted_fields
|
||||
'manage_api_keys',
|
||||
admin_override=True, any_=True)
|
||||
def choose_template(service_id, template_type):
|
||||
if template_type not in ['email', 'sms']:
|
||||
if template_type not in ['email', 'sms', 'letter']:
|
||||
abort(404)
|
||||
if not current_service['can_send_letters'] and template_type == 'letter':
|
||||
abort(403)
|
||||
return render_template(
|
||||
'views/templates/choose.html',
|
||||
templates=[
|
||||
@@ -233,7 +237,7 @@ def check_messages(service_id, template_type, upload_id):
|
||||
max_initial_rows_shown=50,
|
||||
max_errors_shown=50,
|
||||
whitelist=itertools.chain.from_iterable(
|
||||
[user.mobile_number, user.email_address] for user in users
|
||||
[user.name, user.mobile_number, user.email_address] for user in users
|
||||
) if current_service['restricted'] else None,
|
||||
remaining_messages=remaining_messages
|
||||
)
|
||||
|
||||
@@ -11,14 +11,15 @@ from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.main import main
|
||||
from app.utils import user_has_permissions
|
||||
from app.main.forms import SMSTemplateForm, EmailTemplateForm
|
||||
from app.main.forms import SMSTemplateForm, EmailTemplateForm, LetterTemplateForm
|
||||
from app.main.views.send import get_example_csv_rows
|
||||
from app import service_api_client, current_service, template_statistics_client
|
||||
|
||||
|
||||
form_objects = {
|
||||
'email': EmailTemplateForm,
|
||||
'sms': SMSTemplateForm
|
||||
'sms': SMSTemplateForm,
|
||||
'letter': LetterTemplateForm
|
||||
}
|
||||
|
||||
page_headings = {
|
||||
@@ -74,8 +75,10 @@ def view_template_version(service_id, template_id, version):
|
||||
@login_required
|
||||
@user_has_permissions('manage_templates', admin_override=True)
|
||||
def add_service_template(service_id, template_type):
|
||||
if template_type not in ['sms', 'email']:
|
||||
if template_type not in ['sms', 'email', 'letter']:
|
||||
abort(404)
|
||||
if not current_service['can_send_letters'] and template_type == 'letter':
|
||||
abort(403)
|
||||
|
||||
form = form_objects[template_type]()
|
||||
if form.validate_on_submit():
|
||||
|
||||
Reference in New Issue
Block a user