diff --git a/app/schemas.py b/app/schemas.py index a61dcba11..ed4c914ef 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -311,15 +311,15 @@ class NotificationModelSchema(BaseSchema): class BaseTemplateSchema(BaseSchema): - reply_to = fields.Method("get_reply_to", allow_none=True) + reply_to_text = fields.Method("get_reply_to_text", allow_none=True) def get_reply_to(self, template): - if template.template_type == 'letter': - text = template.get_reply_to_text() - return text return template.reply_to + def get_reply_to_text(self, template): + return template.get_reply_to_text() + class Meta: model = models.Template exclude = ("service_id", "jobs", "service_letter_contact_id") diff --git a/tests/app/template/test_rest.py b/tests/app/template/test_rest.py index 67b46e099..ab2533e0f 100644 --- a/tests/app/template/test_rest.py +++ b/tests/app/template/test_rest.py @@ -581,7 +581,8 @@ def test_create_a_template_with_reply_to(admin_request, sample_user): json_resp = admin_request.post('template.create_template', service_id=service.id, _data=data, _expected_status=201) assert json_resp['data']['template_type'] == 'letter' - assert json_resp['data']['reply_to'] == str(letter_contact.contact_block) + assert json_resp['data']['reply_to'] == str(letter_contact.id) + assert json_resp['data']['reply_to_text'] == letter_contact.contact_block template = Template.query.get(json_resp['data']['id']) from app.schemas import template_schema @@ -622,7 +623,8 @@ def test_get_template_reply_to(client, sample_letter_template): json_resp = json.loads(resp.get_data(as_text=True)) assert 'service_letter_contact_id' not in json_resp['data'] - assert json_resp['data']['reply_to'] == letter_contact.contact_block + assert json_resp['data']['reply_to'] == str(letter_contact.id) + assert json_resp['data']['reply_to_text'] == letter_contact.contact_block assert not json_resp['data']['is_letter_contact_blank']