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") @user_has_permissions("manage_templates")
def add_service_template(service_id, template_type, template_folder_id=None): 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: if template_type not in current_service.available_template_types:
return redirect( return redirect(
url_for( url_for(
@@ -567,6 +569,7 @@ def abort_403_if_not_admin_user():
) )
@user_has_permissions("manage_templates") @user_has_permissions("manage_templates")
def edit_service_template(service_id, template_id): def edit_service_template(service_id, template_id):
print("ENTER EDIT_SERVICE_TEMPLATE")
template = current_service.get_template_with_user_permission_or_403( template = current_service.get_template_with_user_permission_or_403(
template_id, current_user template_id, current_user
) )
@@ -667,6 +670,7 @@ def count_content_length(service_id, template_type):
current_service, current_service,
) )
) )
print(f"ERROR AND MESSAGE {error} {message}")
return jsonify( return jsonify(
{ {
@@ -681,6 +685,16 @@ def count_content_length(service_id, template_type):
def _get_content_count_error_and_message_for_template(template): def _get_content_count_error_and_message_for_template(template):
if template.template_type == "sms": 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(): if template.is_message_too_long():
return True, ( return True, (
f"You have " f"You have "
@@ -690,10 +704,10 @@ def _get_content_count_error_and_message_for_template(template):
if template.placeholders: if template.placeholders:
return False, ( 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)} "
f"(not including personalization)" f"(not including personalization). {warning}"
) )
return False, ( 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>
<div class="grid-row"> <div class="grid-row">
<div class="grid-col-12"> <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" <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') }}" data-updates-url="{{ url_for('.count_content_length', service_id=current_service.id, template_type='sms') }}"
aria-live="polite"> aria-live="polite">