mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Link directly to email branding "something else"
Previously we duplicated the "something else" email branding form on its own page and embedded in the choices form (if it was the only option). See [^1] for how this looks - it's inconsistent. This DRYs-up the "something else" form by bypassing the choices form when "something else" is the only option. I've also tweaked the "Back" button to be consistent with this behaviour. Making this change also simplifies the choices form, which we'll be adding pool options to shortly. I'd like to make the letters form consistent, but let's see how emails pan out first. Note that the choices form will now show a single radio button if "something else" is the only option. I think that's OK as nothing will link to the page, and the form still works. [^1]: https://github.com/alphagov/notifications-admin/pull/4163#issuecomment-1050088088
This commit is contained in:
@@ -2245,10 +2245,7 @@ class BrandingOptions(StripWhitespaceForm):
|
||||
return self.options.choices == (self.FALLBACK_OPTION,)
|
||||
|
||||
def validate_something_else(self, field):
|
||||
if self.branding_type == 'email':
|
||||
if self.something_else_is_only_option and not field.data:
|
||||
raise ValidationError('Cannot be empty')
|
||||
elif self.branding_type == 'letter':
|
||||
if self.branding_type == 'letter':
|
||||
if (
|
||||
self.something_else_is_only_option
|
||||
or self.options.data == self.FALLBACK_OPTION_VALUE
|
||||
|
||||
@@ -88,7 +88,8 @@ NHS_BRANDING_ID = 'a7dc4e56-660b-4db7-8cff-12c37b12b5ea'
|
||||
def service_settings(service_id):
|
||||
return render_template(
|
||||
'views/service-settings.html',
|
||||
service_permissions=PLATFORM_ADMIN_SERVICE_PERMISSIONS
|
||||
service_permissions=PLATFORM_ADMIN_SERVICE_PERMISSIONS,
|
||||
email_branding_options=BrandingOptions(current_service, branding_type='email')
|
||||
)
|
||||
|
||||
|
||||
@@ -1161,21 +1162,12 @@ def email_branding_request(service_id):
|
||||
form = BrandingOptions(current_service, branding_type='email')
|
||||
branding_name = current_service.email_branding_name
|
||||
if form.validate_on_submit():
|
||||
if form.something_else_is_only_option:
|
||||
create_email_branding_zendesk_ticket(
|
||||
form_option_selected=form.options.data,
|
||||
detail=form.something_else.data,
|
||||
)
|
||||
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
else:
|
||||
return redirect(
|
||||
url_for(
|
||||
f'.email_branding_{form.options.data}',
|
||||
service_id=current_service.id,
|
||||
)
|
||||
return redirect(
|
||||
url_for(
|
||||
f'.email_branding_{form.options.data}',
|
||||
service_id=current_service.id,
|
||||
)
|
||||
)
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/branding/email-branding-options.html',
|
||||
@@ -1261,7 +1253,11 @@ def email_branding_something_else(service_id):
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
|
||||
return render_template('views/service-settings/branding/email-branding-something-else.html', form=form)
|
||||
return render_template(
|
||||
'views/service-settings/branding/email-branding-something-else.html',
|
||||
form=form,
|
||||
branding_options=BrandingOptions(current_service, branding_type='email')
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/letter-branding", methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user