Fix bug when editing letter contact block from letter template page

When viewing a letter template, there is a button to edit the letter
contact block. This should take the user to the page to edit the letter
contact block, but if a service has not set any letter contact blocks, the
button was returning a 404 error.

The code has now been changed so that if the service has no letter contact
blocks the edit button will link to the page to add a letter contact
block.

Pivotal story: https://www.pivotaltracker.com/story/show/152881444
This commit is contained in:
Katie Smith
2017-12-12 12:16:17 +00:00
parent 7ee1cc56ae
commit 87f5a9e124
4 changed files with 54 additions and 3 deletions

View File

@@ -58,7 +58,7 @@ def view_template(service_id, template_id):
if template["template_type"] == "letter":
letter_contact_details = service_api_client.get_letter_contacts(service_id)
default_letter_contact_block_id = next(
(x['id'] for x in letter_contact_details if x['is_default']), "None"
(x['id'] for x in letter_contact_details if x['is_default']), None
)
else:
default_letter_contact_block_id = None