Add an endpoint to count the length of templates

Users sending text messages are sometimes unaware that long messages
will cost more.

Users sending broadcast messages need to be aware that there’s a
character limit, so they can take this into account when planning their
messages.

This commit adds an endpoint which counts the number of characters in
some template content, and returns a snippet of useful info about how
long the message is.

In subsequent commits we’ll be able to use AJAX to fetch this snippet as
the user types.

There’s a surprising amount of complexity in counting the length of
messages. So we’ll need to do this in Python because it would be too
convoluted to re-implement the length counting in client side code, let
alone ensuring it had parity with its Python equivalent.
This commit is contained in:
Chris Hill-Scott
2021-01-06 11:54:27 +00:00
parent 91b54c2d3b
commit 48577b823e
5 changed files with 265 additions and 2 deletions

View File

@@ -164,6 +164,7 @@ class HeaderNavigation(Navigation):
'confirm_edit_user_email',
'confirm_edit_user_mobile_number',
'confirm_redact_template',
'count_content_length',
'conversation',
'conversation_reply',
'conversation_reply_with_template',
@@ -554,6 +555,7 @@ class MainNavigation(Navigation):
'choose_service',
'clear_cache',
'confirm_edit_organisation_name',
'count_content_length',
'conversation_reply_with_template',
'conversation_updates',
'cookies',
@@ -793,6 +795,7 @@ class CaseworkNavigation(Navigation):
'choose_service',
'choose_template_to_copy',
'clear_cache',
'count_content_length',
'edit_organisation_agreement',
'edit_organisation_crown_status',
'edit_organisation_domains',
@@ -1128,6 +1131,7 @@ class OrgNavigation(Navigation):
'confirm_edit_user_email',
'confirm_edit_user_mobile_number',
'confirm_redact_template',
'count_content_length',
'conversation',
'conversation_reply',
'conversation_reply_with_template',