Let users select electoral wards of local authorities

If a library has groups, we should show a link instead of selecting the
group directly.

Then we can give the user the choice of selecting the whole of that
group, or specific areas within the group.

For now the only libraries we have with groups are local authorities,
which group electoral wards.
This commit is contained in:
Chris Hill-Scott
2020-07-31 16:20:37 +01:00
parent 32cc168c23
commit 8570901731
6 changed files with 273 additions and 1 deletions

View File

@@ -2161,3 +2161,23 @@ class BroadcastAreaForm(StripWhitespaceForm):
return cls(choices=[
(area.id, area.name) for area in sorted(library)
])
class BroadcastAreaFormWithSelectAll(BroadcastAreaForm):
select_all = govukCheckboxField('Select all')
@classmethod
def from_library(cls, library, select_all_choice):
instance = super().from_library(library)
(
instance.select_all.area_slug,
instance.select_all.label.text,
) = select_all_choice
return instance
@property
def selected_areas(self):
if self.select_all.data:
return [self.select_all.area_slug]
return self.areas.data