diff --git a/app/main/views/templates.py b/app/main/views/templates.py index 2a725ca42e..a9f8332a61 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -18,11 +18,7 @@ from flask_login import current_user from markupsafe import Markup from notifications_python_client.errors import HTTPError -from notifications_utils import ( - EMAIL_CHAR_COUNT_LIMIT, - SMS_CHAR_COUNT_LIMIT, - TEMPLATE_NAME_CHAR_COUNT_LIMIT, -) +from notifications_utils import TEMPLATE_NAME_CHAR_COUNT_LIMIT from notifications_utils.formatters import nl2br from notifications_utils.recipients import first_column_headings @@ -109,8 +105,7 @@ def delete_preview_data(service_id, template_id=None): redis_client.delete(key) -def get_char_limit_error_msg(template_type): - CHAR_LIMIT = SMS_CHAR_COUNT_LIMIT if template_type == "sms" else EMAIL_CHAR_COUNT_LIMIT +def get_char_limit_error_msg(): return _("Too many characters") @@ -192,7 +187,7 @@ def preview_template(service_id, template_id=None): except HTTPError as e: if e.status_code == 400: if "content" in e.message and any(["character count greater than" in x for x in e.message["content"]]): - error_message = get_char_limit_error_msg(template["template_type"]) + error_message = get_char_limit_error_msg() flash(error_message) elif "name" in e.message and any(["Template name must be less than" in x for x in e.message["name"]]): error_message = (_("Template name must be less than {char_limit} characters")).format( @@ -758,7 +753,7 @@ def add_service_template(service_id, template_type, template_folder_id=None): and "content" in e.message and any(["character count greater than" in x for x in e.message["content"]]) ): - error_message = get_char_limit_error_msg(template_type) + error_message = get_char_limit_error_msg() form.template_content.errors.extend([error_message]) elif "name" in e.message and any(["Template name must be less than" in x for x in e.message["name"]]): error_message = (_("Template name must be less than {char_limit} characters")).format( @@ -886,7 +881,7 @@ def edit_service_template(service_id, template_id): except HTTPError as e: if e.status_code == 400: if "content" in e.message and any(["character count greater than" in x for x in e.message["content"]]): - error_message = get_char_limit_error_msg(template["template_type"]) + error_message = get_char_limit_error_msg() form.template_content.errors.extend([error_message]) elif "name" in e.message and any(["Template name must be less than" in x for x in e.message["name"]]): error_message = (_("Template name must be less than {char_limit} characters")).format( diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index f14294491d..da28bf1cdc 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1400,8 +1400,7 @@ def test_dashboard_daily_limits( assert page.find_all(class_="remaining-messages")[component_index].find(class_="rm-used").text == expected_sent assert page.find_all(class_="remaining-messages")[component_index].find(class_="rm-total").text[3:] == expected_limit assert ( - expected_color - in page.find_all(class_="remaining-messages")[component_index].find(class_="rm-bar-usage").attrs["class"] + expected_color in page.find_all(class_="remaining-messages")[component_index].find(class_="rm-bar-usage").attrs["class"] ) if expect_accessible_message: