From 937aa5af15c919523f2d901adae5da88ae1fd1eb Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Wed, 19 Mar 2025 14:35:22 -0400 Subject: [PATCH] Update templates.py --- app/main/views/templates.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/main/views/templates.py b/app/main/views/templates.py index 1cee80c79..3f779060d 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -695,9 +695,10 @@ def _get_content_count_error_and_message_for_template(template): """Check if the content contains explicitly blocked characters.""" return any(c in BLOCKED_CHARACTERS for c in content) - warning = "" - if contains_blocked_characters(template.content): # Block only disallowed characters + # Check for blocked characters + if contains_blocked_characters(template.content): warning = f"{s1}{s2}" + return False, Markup(warning) # 🚨 ONLY show the warning, hiding "Will be charged..." # If message is too long, return the length error if template.is_message_too_long(): @@ -707,17 +708,13 @@ def _get_content_count_error_and_message_for_template(template): f"too many" ) + # Show charge message as usual if no warning if template.placeholders: return False, Markup( f"Will be charged as {message_count(template.fragment_count, template.template_type)} " - f"(not including personalization). {warning}" + f"(not including personalization)." ) - # If there's a warning, return it alone and hide the "Will be charged as..." text - if warning: - return False, Markup(warning) - - # Otherwise, show the message count as usual return False, Markup( f"Will be charged as {message_count(template.fragment_count, template.template_type)}." )