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:
Ben Thorner
2022-03-02 15:36:28 +00:00
parent cc876194d0
commit 33c6ca0989
6 changed files with 120 additions and 166 deletions

View File

@@ -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