allow downgradeable unicode characters in SMS templates

This commit is contained in:
Leo Hemsted
2017-02-14 17:06:32 +00:00
parent c25fff9032
commit 73a965a3c6
2 changed files with 24 additions and 6 deletions

View File

@@ -1,7 +1,8 @@
from wtforms import ValidationError
from notifications_utils.template import Template
from notifications_utils.gsm import get_non_gsm_characters
from notifications_utils.gsm import get_non_gsm_compatible_characters
from app import formatted_list
from app.main._blacklisted_passwords import blacklisted_passwords
from app.utils import (
Spreadsheet,
@@ -54,8 +55,10 @@ class NoCommasInPlaceHolders:
class OnlyGSMCharacters:
def __call__(self, form, field):
non_gsm_characters = get_non_gsm_characters(field.data)
non_gsm_characters = sorted(list(get_non_gsm_compatible_characters(field.data)))
if non_gsm_characters:
raise ValidationError('The following characters are not allowed in text messages: {}'.format(
', '.join(non_gsm_characters)
))
raise ValidationError(
'You cant use {} in text messages. They wont show up properly on everyones phones.'.format(
formatted_list(non_gsm_characters, conjunction='or')
)
)