Add a form for choosing areas

Picking multiple areas at once definitely feels like a need, so let’s
make them checkboxes.
This commit is contained in:
Chris Hill-Scott
2020-07-06 10:53:16 +01:00
parent 49444221e9
commit 29ad5cf510
5 changed files with 42 additions and 46 deletions

View File

@@ -1809,3 +1809,18 @@ class AcceptAgreementForm(StripWhitespaceForm):
float(field.data)
except (TypeError, ValueError):
raise ValidationError("Must be a number")
class BroadcastAreaForm(StripWhitespaceForm):
areas = MultiCheckboxField('Choose areas to broadcast to')
def __init__(self, choices, *args, **kwargs):
super().__init__(*args, **kwargs)
self.areas.choices = choices
@classmethod
def from_library(cls, library):
return cls(choices=[
(area.id, area.name) for area in sorted(library)
])