fix flake8

This commit is contained in:
Kenneth Kehl
2023-11-27 14:49:20 -08:00
parent 74ace43668
commit c74ab6ff27
2 changed files with 18 additions and 4 deletions

View File

@@ -503,6 +503,8 @@ def delete_template_folder(service_id, template_folder_id):
)
@user_has_permissions("manage_templates")
def add_service_template(service_id, template_type, template_folder_id=None):
print("ENTER ADD_SERVICE_TEMPLATE")
if template_type not in current_service.available_template_types:
return redirect(
url_for(
@@ -567,6 +569,7 @@ def abort_403_if_not_admin_user():
)
@user_has_permissions("manage_templates")
def edit_service_template(service_id, template_id):
print("ENTER EDIT_SERVICE_TEMPLATE")
template = current_service.get_template_with_user_permission_or_403(
template_id, current_user
)
@@ -667,6 +670,7 @@ def count_content_length(service_id, template_type):
current_service,
)
)
print(f"ERROR AND MESSAGE {error} {message}")
return jsonify(
{
@@ -681,6 +685,16 @@ def count_content_length(service_id, template_type):
def _get_content_count_error_and_message_for_template(template):
if template.template_type == "sms":
islatin1 = lambda s: bool(s.encode(encoding="latin-1", errors="strict"))
warning = ""
try:
islatin1(template.content)
except UnicodeEncodeError:
warning = " Use of characters outside the iso-latin-1 character set will result in additional characters and may not display properly on older phones."
if template.is_message_too_long():
return True, (
f"You have "
@@ -690,10 +704,10 @@ def _get_content_count_error_and_message_for_template(template):
if template.placeholders:
return False, (
f"Will be charged as {message_count(template.fragment_count, template.template_type)} "
f"(not including personalization)"
f"(not including personalization). {warning}"
)
return False, (
f"Will be charged as {message_count(template.fragment_count, template.template_type)} "
f"Will be charged as {message_count(template.fragment_count, template.template_type)}. {warning} "
)

View File

@@ -50,7 +50,7 @@
</div>
<div class="grid-row">
<div class="grid-col-12">
<div class="template-content-count">
<div class="template-content-count" bg="blue" spacing="1">
<div data-module="update-status" data-target="template_content"
data-updates-url="{{ url_for('.count_content_length', service_id=current_service.id, template_type='sms') }}"
aria-live="polite">
@@ -69,7 +69,7 @@
</p>
</div>
</div>
<div class="tablet:grid-col-9 mobile-lg:grid-col-12">
<h2 id="help" class="font-body-xl margin-top-2">How to customize your message</h2>
<div class="usa-accordion usa-accordion--bordered usa-accordion--multiselectable maxw-mobile-lg" data-allow-multiple>