mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Consolidate callback forms and convert them to gov uk frontend
We had two identical callback form classes. One for delivery callbacks and one for inbound sms callbacks. Since they did not differ I consolidated them into one CallbackForm class that they both inherited from previously. I also substituted field classes for this form with new fields that cooperate with gov uk frontend.
This commit is contained in:
@@ -34,7 +34,6 @@ from wtforms import (
|
||||
TextAreaField,
|
||||
ValidationError,
|
||||
validators,
|
||||
widgets,
|
||||
)
|
||||
from wtforms.fields.html5 import EmailField, SearchField, TelField
|
||||
from wtforms.validators import URL, DataRequired, Length, Optional, Regexp
|
||||
@@ -1804,10 +1803,6 @@ class PlaceholderForm(StripWhitespaceForm):
|
||||
pass
|
||||
|
||||
|
||||
class PasswordFieldShowHasContent(StringField):
|
||||
widget = widgets.PasswordInput(hide_value=False)
|
||||
|
||||
|
||||
class ServiceInboundNumberForm(StripWhitespaceForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -1820,37 +1815,21 @@ class ServiceInboundNumberForm(StripWhitespaceForm):
|
||||
|
||||
|
||||
class CallbackForm(StripWhitespaceForm):
|
||||
url = GovukTextInputField(
|
||||
"URL",
|
||||
validators=[DataRequired(message='Cannot be empty'),
|
||||
Regexp(regex="^https.*", message='Must be a valid https URL')]
|
||||
)
|
||||
bearer_token = GovukPasswordField(
|
||||
"Bearer token",
|
||||
validators=[DataRequired(message='Cannot be empty'),
|
||||
Length(min=10, message='Must be at least 10 characters')]
|
||||
)
|
||||
|
||||
def validate(self):
|
||||
return super().validate() or self.url.data == ''
|
||||
|
||||
|
||||
class ServiceReceiveMessagesCallbackForm(CallbackForm):
|
||||
url = StringField(
|
||||
"URL",
|
||||
validators=[DataRequired(message='Cannot be empty'),
|
||||
Regexp(regex="^https.*", message='Must be a valid https URL')]
|
||||
)
|
||||
bearer_token = PasswordFieldShowHasContent(
|
||||
"Bearer token",
|
||||
validators=[DataRequired(message='Cannot be empty'),
|
||||
Length(min=10, message='Must be at least 10 characters')]
|
||||
)
|
||||
|
||||
|
||||
class ServiceDeliveryStatusCallbackForm(CallbackForm):
|
||||
url = StringField(
|
||||
"URL",
|
||||
validators=[DataRequired(message='Cannot be empty'),
|
||||
Regexp(regex="^https.*", message='Must be a valid https URL')]
|
||||
)
|
||||
bearer_token = PasswordFieldShowHasContent(
|
||||
"Bearer token",
|
||||
validators=[DataRequired(message='Cannot be empty'),
|
||||
Length(min=10, message='Must be at least 10 characters')]
|
||||
)
|
||||
|
||||
|
||||
class InternationalSMSForm(StripWhitespaceForm):
|
||||
enabled = RadioField(
|
||||
'Send text messages to international phone numbers',
|
||||
|
||||
Reference in New Issue
Block a user