Bug fix: Set default letter sender address on template creation

We spotted then when creating a new letter template it was not
having the default letter sender address added to it. This commit
fixes that bug by adding it if one exists.

Note, use of new walrus operator
https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions
This commit is contained in:
David McDonald
2022-04-11 17:15:10 +01:00
parent c73f0bb414
commit 0929efb579
4 changed files with 72 additions and 5 deletions

View File

@@ -96,8 +96,11 @@ def create_template(service_id):
errors = {'template_type': [message]}
raise InvalidRequest(errors, 403)
if not new_template.postage and new_template.template_type == LETTER_TYPE:
new_template.postage = SECOND_CLASS
if new_template.template_type == LETTER_TYPE:
if default_letter_contact := fetched_service.get_default_letter_contact():
new_template.reply_to = default_letter_contact.id
if not new_template.postage:
new_template.postage = SECOND_CLASS
new_template.service = fetched_service