Add allowed brands for organisations#2923
Open
theseanything wants to merge 7 commits into
Open
Conversation
73da06e to
fd53f55
Compare
Brands are a global list, but each organisation should only be able to use brands it has been granted. Super admins can now add and remove an organisation's brands from the organisation page. The add page uses an autocomplete so it works with hundreds of brands.
The form brand picker offered every brand configured in settings.yml to any form. Source the options from the brands allowed for the form's organisation instead, so organisations can only apply brands they have been granted. Options keep using the brand slug, so existing form brand_id values are unaffected.
Removing a brand from an organisation stops new forms selecting it, but forms already using the brand keep it. Make this clear on the organisation page so super admins know what removing a brand does.
The same empty-rawAttribute detection was copied in three places across UsersController and OrganisationBrandsController. Move it to WebController so every autocomplete form clears stale values the same way.
The custom validation re-implemented the "not already added" rule that available_brands already expresses, so the two could drift. Validate against available_brands directly instead.
Validating a brand id only needs slugs, so pluck them rather than instantiating every Brand. Memoise the brands relation as it is used by both validation and the options list.
Show the guidance even when an organisation has no brands, and reword it to explain that adding a brand makes it available for the organisation's forms to use.
519fc7b to
ea669ad
Compare
|
🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2923.admin.review.forms.service.gov.uk/ It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready For the sign in details and more information, see the review apps wiki page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brands are a global list, but each organisation should only be able to use brands it has been granted. This can help make sure that brands that each organisation see's is manageable list and relevant (i.e. Croydon council is unlikely going to use Hackney council branding). It also prevents user creating or impersonating organisations for which they're not associated with.
The management is only available via the organisations page and can only be done by a super admin.
The UI uses the autocomplete select, in case the list of brands becomes very long (potentially, e.g. each local council has its own brand).