mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-13 10:28:51 -04:00
Rename branding forms to clarify who they're for
I've often struggled to find the form associated with a particular page due to the overlapping names e.g. "SetEmailBranding" sounds more like the radio button form a user sees than "BrandingOptions". Almost every form in forms.py also ends with "Form", so this also makes the branding forms consistent with that naming convention.
This commit is contained in:
@@ -1876,7 +1876,7 @@ class ServiceSwitchChannelForm(ServiceOnOffSettingForm):
|
||||
super().__init__(name, *args, **kwargs)
|
||||
|
||||
|
||||
class SetEmailBranding(StripWhitespaceForm):
|
||||
class AdminSetEmailBrandingForm(StripWhitespaceForm):
|
||||
|
||||
branding_style = GovukRadiosFieldWithNoneOption(
|
||||
'Branding style',
|
||||
@@ -1900,17 +1900,17 @@ class SetEmailBranding(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
|
||||
class SetLetterBranding(SetEmailBranding):
|
||||
class AdminSetLetterBrandingForm(AdminSetEmailBrandingForm):
|
||||
# form is the same, but instead of GOV.UK we have None as a valid option
|
||||
DEFAULT = (FieldWithNoneOption.NONE_OPTION_VALUE, 'None')
|
||||
|
||||
|
||||
class PreviewBranding(StripWhitespaceForm):
|
||||
class AdminPreviewBrandingForm(StripWhitespaceForm):
|
||||
|
||||
branding_style = HiddenFieldWithNoneOption('branding_style')
|
||||
|
||||
|
||||
class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
class AdminEditEmailBrandingForm(StripWhitespaceForm):
|
||||
name = GovukTextInputField('Name of brand')
|
||||
text = GovukTextInputField('Text')
|
||||
colour = GovukTextInputField(
|
||||
@@ -1939,6 +1939,10 @@ class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
raise ValidationError('This field is required')
|
||||
|
||||
|
||||
class AdminEditLetterBrandingForm(StripWhitespaceForm):
|
||||
name = GovukTextInputField('Name of brand', validators=[DataRequired()])
|
||||
|
||||
|
||||
class SVGFileUpload(StripWhitespaceForm):
|
||||
file = FileField_wtf(
|
||||
'Upload an SVG logo',
|
||||
@@ -1951,10 +1955,6 @@ class SVGFileUpload(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
|
||||
class ServiceLetterBrandingDetails(StripWhitespaceForm):
|
||||
name = GovukTextInputField('Name of brand', validators=[DataRequired()])
|
||||
|
||||
|
||||
class PDFUploadForm(StripWhitespaceForm):
|
||||
file = FileField_wtf(
|
||||
'Upload a letter in PDF format',
|
||||
|
||||
@@ -2,7 +2,7 @@ from flask import current_app, redirect, render_template, session, url_for
|
||||
|
||||
from app import email_branding_client
|
||||
from app.main import main
|
||||
from app.main.forms import SearchByNameForm, ServiceUpdateEmailBranding
|
||||
from app.main.forms import AdminEditEmailBrandingForm, SearchByNameForm
|
||||
from app.s3_client.s3_logo_client import (
|
||||
TEMP_TAG,
|
||||
delete_email_temp_file,
|
||||
@@ -32,7 +32,7 @@ def email_branding():
|
||||
def update_email_branding(branding_id, logo=None):
|
||||
email_branding = email_branding_client.get_email_branding(branding_id)['email_branding']
|
||||
|
||||
form = ServiceUpdateEmailBranding(
|
||||
form = AdminEditEmailBrandingForm(
|
||||
name=email_branding['name'],
|
||||
text=email_branding['text'],
|
||||
colour=email_branding['colour'],
|
||||
@@ -86,7 +86,7 @@ def update_email_branding(branding_id, logo=None):
|
||||
@main.route("/email-branding/create/<logo>", methods=['GET', 'POST'])
|
||||
@user_is_platform_admin
|
||||
def create_email_branding(logo=None):
|
||||
form = ServiceUpdateEmailBranding(brand_type='org')
|
||||
form = AdminEditEmailBrandingForm(brand_type='org')
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.file.data:
|
||||
|
||||
@@ -12,8 +12,8 @@ from notifications_python_client.errors import HTTPError
|
||||
from app import letter_branding_client
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
AdminEditLetterBrandingForm,
|
||||
SearchByNameForm,
|
||||
ServiceLetterBrandingDetails,
|
||||
SVGFileUpload,
|
||||
)
|
||||
from app.s3_client.s3_logo_client import (
|
||||
@@ -48,7 +48,7 @@ def update_letter_branding(branding_id, logo=None):
|
||||
letter_branding = letter_branding_client.get_letter_branding(branding_id)
|
||||
|
||||
file_upload_form = SVGFileUpload()
|
||||
letter_branding_details_form = ServiceLetterBrandingDetails(
|
||||
letter_branding_details_form = AdminEditLetterBrandingForm(
|
||||
name=letter_branding['name'],
|
||||
)
|
||||
|
||||
@@ -123,7 +123,7 @@ def update_letter_branding(branding_id, logo=None):
|
||||
@user_is_platform_admin
|
||||
def create_letter_branding(logo=None):
|
||||
file_upload_form = SVGFileUpload()
|
||||
letter_branding_details_form = ServiceLetterBrandingDetails()
|
||||
letter_branding_details_form = AdminEditLetterBrandingForm()
|
||||
|
||||
file_upload_form_submitted = file_upload_form.file.data
|
||||
details_form_submitted = request.form.get('operation') == 'branding-details'
|
||||
|
||||
@@ -19,6 +19,9 @@ from app.main import main
|
||||
from app.main.forms import (
|
||||
AddGPOrganisationForm,
|
||||
AddNHSLocalOrganisationForm,
|
||||
AdminPreviewBrandingForm,
|
||||
AdminSetEmailBrandingForm,
|
||||
AdminSetLetterBrandingForm,
|
||||
BillingDetailsForm,
|
||||
EditNotesForm,
|
||||
GoLiveNotesForm,
|
||||
@@ -28,12 +31,9 @@ from app.main.forms import (
|
||||
OrganisationCrownStatusForm,
|
||||
OrganisationDomainsForm,
|
||||
OrganisationOrganisationTypeForm,
|
||||
PreviewBranding,
|
||||
RenameOrganisationForm,
|
||||
SearchByNameForm,
|
||||
SearchUsersForm,
|
||||
SetEmailBranding,
|
||||
SetLetterBranding,
|
||||
)
|
||||
from app.main.views.dashboard import (
|
||||
get_tuples_of_financial_years,
|
||||
@@ -405,7 +405,7 @@ def edit_organisation_email_branding(org_id):
|
||||
|
||||
email_branding = email_branding_client.get_all_email_branding()
|
||||
|
||||
form = SetEmailBranding(
|
||||
form = AdminSetEmailBrandingForm(
|
||||
all_branding_options=get_branding_as_value_and_label(email_branding),
|
||||
current_branding=current_organisation.email_branding_id,
|
||||
)
|
||||
@@ -430,7 +430,7 @@ def organisation_preview_email_branding(org_id):
|
||||
|
||||
branding_style = request.args.get('branding_style', None)
|
||||
|
||||
form = PreviewBranding(branding_style=branding_style)
|
||||
form = AdminPreviewBrandingForm(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
current_organisation.update(
|
||||
@@ -451,7 +451,7 @@ def organisation_preview_email_branding(org_id):
|
||||
def edit_organisation_letter_branding(org_id):
|
||||
letter_branding = letter_branding_client.get_all_letter_branding()
|
||||
|
||||
form = SetLetterBranding(
|
||||
form = AdminSetLetterBrandingForm(
|
||||
all_branding_options=get_branding_as_value_and_label(letter_branding),
|
||||
current_branding=current_organisation.letter_branding_id,
|
||||
)
|
||||
@@ -475,7 +475,7 @@ def edit_organisation_letter_branding(org_id):
|
||||
def organisation_preview_letter_branding(org_id):
|
||||
branding_style = request.args.get('branding_style')
|
||||
|
||||
form = PreviewBranding(branding_style=branding_style)
|
||||
form = AdminPreviewBrandingForm(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
current_organisation.update(
|
||||
|
||||
@@ -38,6 +38,9 @@ from app.extensions import zendesk_client
|
||||
from app.formatters import email_safe
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
AdminPreviewBrandingForm,
|
||||
AdminSetEmailBrandingForm,
|
||||
AdminSetLetterBrandingForm,
|
||||
BillingDetailsForm,
|
||||
BrandingOptions,
|
||||
EditNotesForm,
|
||||
@@ -45,7 +48,6 @@ from app.main.forms import (
|
||||
FreeSMSAllowance,
|
||||
LinkOrganisationsForm,
|
||||
MessageLimit,
|
||||
PreviewBranding,
|
||||
RateLimit,
|
||||
RenameServiceForm,
|
||||
SearchByNameForm,
|
||||
@@ -62,8 +64,6 @@ from app.main.forms import (
|
||||
ServiceReplyToEmailForm,
|
||||
ServiceSmsSenderForm,
|
||||
ServiceSwitchChannelForm,
|
||||
SetEmailBranding,
|
||||
SetLetterBranding,
|
||||
SMSPrefixForm,
|
||||
SomethingElseBrandingForm,
|
||||
)
|
||||
@@ -1022,7 +1022,7 @@ def set_rate_limit(service_id):
|
||||
def service_set_email_branding(service_id):
|
||||
email_branding = email_branding_client.get_all_email_branding()
|
||||
|
||||
form = SetEmailBranding(
|
||||
form = AdminSetEmailBrandingForm(
|
||||
all_branding_options=get_branding_as_value_and_label(email_branding),
|
||||
current_branding=current_service.email_branding_id,
|
||||
)
|
||||
@@ -1046,7 +1046,7 @@ def service_set_email_branding(service_id):
|
||||
def service_preview_email_branding(service_id):
|
||||
branding_style = request.args.get('branding_style', None)
|
||||
|
||||
form = PreviewBranding(branding_style=branding_style)
|
||||
form = AdminPreviewBrandingForm(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
current_service.update(
|
||||
@@ -1067,7 +1067,7 @@ def service_preview_email_branding(service_id):
|
||||
def service_set_letter_branding(service_id):
|
||||
letter_branding = letter_branding_client.get_all_letter_branding()
|
||||
|
||||
form = SetLetterBranding(
|
||||
form = AdminSetLetterBrandingForm(
|
||||
all_branding_options=get_branding_as_value_and_label(letter_branding),
|
||||
current_branding=current_service.letter_branding_id,
|
||||
)
|
||||
@@ -1091,7 +1091,7 @@ def service_set_letter_branding(service_id):
|
||||
def service_preview_letter_branding(service_id):
|
||||
branding_style = request.args.get('branding_style')
|
||||
|
||||
form = PreviewBranding(branding_style=branding_style)
|
||||
form = AdminPreviewBrandingForm(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
current_service.update(
|
||||
|
||||
Reference in New Issue
Block a user