Skip to content

Commit

Permalink
fixup! basic bulk assignment page
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed May 16, 2024
1 parent b42f3f6 commit 8996316
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crowdsourcer/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,16 @@ class VolunteerBulkAssignForm(Form):
required=True,
label="Number of assignments per volunteer",
)
response_type = ChoiceField(
required=True, choices=[(rt.type, rt.type) for rt in ResponseType.objects.all()]
)
response_type = ChoiceField(required=True, choices=[])
session = CharField(required=True, widget=HiddenInput)
always_assign = BooleanField(
required=False, help_text="Override checks and assign as much as possible"
)

def __init__(self, response_choices, **kwargs):
super().__init__(**kwargs)
self.fields["response_type"].choices = response_choices

def clean(self):
data = self.cleaned_data.get("volunteer_list")

Expand Down
6 changes: 6 additions & 0 deletions crowdsourcer/views/volunteers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ def get_initial(self):
kwargs["session"] = self.request.current_session.label
return kwargs

def get_form(self, form_class=None):
if form_class is None:
form_class = self.form_class

return form_class([(rt.type, rt.type) for rt in ResponseType.objects.all()])

def get_success_url(self):
return reverse(
"session_urls:list_volunteers",
Expand Down

0 comments on commit 8996316

Please sign in to comment.