mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Merge pull request #3672 from alphagov/no-personalisation-broadcast
Don’t allow or highlight personalisation in broadcast templates
This commit is contained in:
@@ -47,6 +47,7 @@ from app.main.validators import (
|
||||
MustContainAlphanumericCharacters,
|
||||
NoCommasInPlaceHolders,
|
||||
NoEmbeddedImagesInSVG,
|
||||
NoPlaceholders,
|
||||
OnlySMSCharacters,
|
||||
ValidEmail,
|
||||
ValidGovEmail,
|
||||
@@ -1217,6 +1218,7 @@ class SMSTemplateForm(BaseTemplateForm):
|
||||
class BroadcastTemplateForm(SMSTemplateForm):
|
||||
def validate_template_content(self, field):
|
||||
OnlySMSCharacters(template_type='broadcast')(None, field)
|
||||
NoPlaceholders()(None, field)
|
||||
|
||||
|
||||
class LetterAddressForm(StripWhitespaceForm):
|
||||
|
||||
@@ -108,6 +108,18 @@ class OnlySMSCharacters:
|
||||
)
|
||||
|
||||
|
||||
class NoPlaceholders:
|
||||
|
||||
def __init__(self, message=None):
|
||||
self.message = message or (
|
||||
'You can’t use ((double brackets)) to personalise this message'
|
||||
)
|
||||
|
||||
def __call__(self, form, field):
|
||||
if Field(field.data).placeholders:
|
||||
raise ValidationError(self.message)
|
||||
|
||||
|
||||
class LettersNumbersFullStopsAndUnderscoresOnly:
|
||||
|
||||
regex = re.compile(r'^[a-zA-Z0-9\s\._]+$')
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
}) }}
|
||||
</div>
|
||||
<div class="govuk-grid-column-two-thirds">
|
||||
{{ textbox(form.template_content, highlight_placeholders=True, width='1-1', rows=5) }}
|
||||
{{ textbox(form.template_content, highlight_placeholders=False, width='1-1', rows=5) }}
|
||||
{{ sticky_page_footer('Save') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user