From 8f7f99234b5e26204a3d7be783123089505ade44 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Mon, 18 Nov 2019 16:16:28 +0000 Subject: [PATCH] use `Template.is_message_too_long` rather than content_count directly this function returns false for emails and letters so we can clean up the code and reduce duplication a little bit --- app/notifications/rest.py | 2 +- app/template/rest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/notifications/rest.py b/app/notifications/rest.py index aa4be0ea9..ac8c63791 100644 --- a/app/notifications/rest.py +++ b/app/notifications/rest.py @@ -200,7 +200,7 @@ def create_template_object_for_notification(template, personalisation): if ( template_object.template_type == SMS_TYPE and - template_object.content_count > SMS_CHAR_COUNT_LIMIT + template_object.is_message_too_long() ): message = 'Content has a character count greater than the limit of {}'.format(SMS_CHAR_COUNT_LIMIT) errors = {'content': [message]} diff --git a/app/template/rest.py b/app/template/rest.py index b77df5741..61f07d105 100644 --- a/app/template/rest.py +++ b/app/template/rest.py @@ -49,7 +49,7 @@ def _content_count_greater_than_limit(content, template_type): if template_type != SMS_TYPE: return False template = SMSMessageTemplate({'content': content, 'template_type': template_type}) - return template.content_count > SMS_CHAR_COUNT_LIMIT + return template.is_message_too_long() def validate_parent_folder(template_json):