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
This commit is contained in:
Leo Hemsted
2019-11-18 16:16:28 +00:00
parent 5e9a21f5d0
commit 8f7f99234b
2 changed files with 2 additions and 2 deletions

View File

@@ -200,7 +200,7 @@ def create_template_object_for_notification(template, personalisation):
if ( if (
template_object.template_type == SMS_TYPE and 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) message = 'Content has a character count greater than the limit of {}'.format(SMS_CHAR_COUNT_LIMIT)
errors = {'content': [message]} errors = {'content': [message]}

View File

@@ -49,7 +49,7 @@ def _content_count_greater_than_limit(content, template_type):
if template_type != SMS_TYPE: if template_type != SMS_TYPE:
return False return False
template = SMSMessageTemplate({'content': content, 'template_type': template_type}) 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): def validate_parent_folder(template_json):