Apply sender to template when adding

If you’ve come from a template to add a new letter sender then it’s
because you want those words on that template. This commit adds the
extra API call to make that happen.
This commit is contained in:
Chris Hill-Scott
2019-07-08 11:20:28 +01:00
parent 90f56353ab
commit 7fef51aa6a
3 changed files with 23 additions and 4 deletions

View File

@@ -706,14 +706,20 @@ def service_add_letter_contact(service_id):
form = ServiceLetterContactBlockForm()
first_contact_block = current_service.count_letter_contact_details == 0
if form.validate_on_submit():
service_api_client.add_letter_contact(
new_letter_contact = service_api_client.add_letter_contact(
current_service.id,
contact_block=form.letter_contact_block.data.replace('\r', '') or None,
is_default=first_contact_block if first_contact_block else form.is_default.data
)
if request.args.get('from_template'):
from_template = request.args.get('from_template')
if from_template:
service_api_client.update_service_template_sender(
service_id,
from_template,
new_letter_contact['data']['id'],
)
return redirect(
url_for('.view_template', service_id=service_id, template_id=request.args.get('from_template'))
url_for('.view_template', service_id=service_id, template_id=from_template)
)
return redirect(url_for('.service_letter_contact_details', service_id=service_id))
return render_template(