Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
[carpentries#2065] Update signup state change view
Browse files Browse the repository at this point in the history
  • Loading branch information
pbanaszkiewicz committed Apr 3, 2022
1 parent 273f6fc commit ccf6636
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions amy/recruitment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get_initial(self) -> dict:
except Event.workshoprequest.RelatedObjectDoesNotExist:
return {}

def form_valid(self, form):
def form_valid(self, form: InstructorRecruitmentCreateForm):
self.object: InstructorRecruitment = form.save(commit=False)
self.object.assigned_to = self.request.user
self.object.event = self.event
Expand Down Expand Up @@ -225,7 +225,7 @@ def get_context_data(self, **kwargs) -> dict:


class InstructorRecruitmentSignupChangeState(FormMixin, View):
"""POST requests for editing (confirming or deleting) the instructor signup."""
"""POST requests for editing (confirming or declining) the instructor signup."""

form_class = InstructorRecruitmentSignupChangeStateForm

Expand All @@ -239,9 +239,13 @@ def form_invalid(self, form):
return HttpResponseRedirect(self.get_success_url())

def form_valid(self, form):
# edit object
self.object.state = "a" if form.cleaned_data["action"] == "confirm" else "d"
action_to_state_mapping = {
"config": "a",
"decline": "d",
}
self.object.state = action_to_state_mapping[form.cleaned_data["action"]]
self.object.save()

return super().form_valid(form)

def post(self, request, *args, **kwargs):
Expand Down

0 comments on commit ccf6636

Please sign in to comment.