mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user