mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 04:09:46 -04:00
Remove branding_type from set_email_branding page
Includes updates to the controller so branding_type is got from the email_branding model instead of from user input. Follows on from: https://github.com/alphagov/notifications-admin/pull/2249
This commit is contained in:
@@ -682,23 +682,6 @@ class ServiceSwitchLettersForm(StripWhitespaceForm):
|
||||
|
||||
class ServiceSetBranding(StripWhitespaceForm):
|
||||
|
||||
def __init__(self, email_branding=[], *args, **kwargs):
|
||||
self.branding_style.choices = email_branding
|
||||
super(ServiceSetBranding, self).__init__(*args, **kwargs)
|
||||
|
||||
branding_type = RadioField(
|
||||
'Branding type',
|
||||
choices=[
|
||||
('govuk', 'GOV.UK only'),
|
||||
('both', 'GOV.UK and branding'),
|
||||
('org', 'Branding only'),
|
||||
('org_banner', 'Branding banner')
|
||||
],
|
||||
validators=[
|
||||
DataRequired()
|
||||
]
|
||||
)
|
||||
|
||||
branding_style = RadioField(
|
||||
'Branding style',
|
||||
validators=[
|
||||
@@ -709,7 +692,6 @@ class ServiceSetBranding(StripWhitespaceForm):
|
||||
|
||||
class ServicePreviewBranding(StripWhitespaceForm):
|
||||
|
||||
branding_type = HiddenField('branding_type')
|
||||
branding_style = HiddenField('branding_style')
|
||||
|
||||
|
||||
|
||||
@@ -868,9 +868,8 @@ def set_free_sms_allowance(service_id):
|
||||
@user_is_platform_admin
|
||||
def service_set_email_branding(service_id):
|
||||
email_branding = email_branding_client.get_all_email_branding()
|
||||
branding_type = current_service.get('branding')
|
||||
|
||||
form = ServiceSetBranding(branding_type=branding_type)
|
||||
form = ServiceSetBranding()
|
||||
|
||||
# dynamically create org choices, including the null option
|
||||
email_brandings = sorted(get_branding_as_value_and_label(email_branding),
|
||||
@@ -880,7 +879,7 @@ def service_set_email_branding(service_id):
|
||||
if form.validate_on_submit():
|
||||
branding_style = None if form.branding_style.data == 'None' else form.branding_style.data
|
||||
return redirect(url_for('.service_preview_email_branding', service_id=service_id,
|
||||
branding_type=form.branding_type.data, branding_style=branding_style))
|
||||
branding_style=branding_style))
|
||||
|
||||
form.branding_style.data = current_service['email_branding'] or 'None'
|
||||
|
||||
@@ -897,16 +896,14 @@ def service_set_email_branding(service_id):
|
||||
@login_required
|
||||
@user_is_platform_admin
|
||||
def service_preview_email_branding(service_id):
|
||||
branding_type = request.args.get('branding_type', None)
|
||||
branding_style = request.args.get('branding_style', None)
|
||||
|
||||
form = ServicePreviewBranding(branding_type=branding_type, branding_style=branding_style)
|
||||
form = ServicePreviewBranding(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
branding_style = None if form.branding_style.data == 'None' else form.branding_style.data
|
||||
service_api_client.update_service(
|
||||
service_id,
|
||||
branding=form.branding_type.data,
|
||||
email_branding=branding_style
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
Reference in New Issue
Block a user