Fix add organizer view
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
fc6e2593b4
commit
2a545dae10
|
@ -92,21 +92,17 @@ class AddOrganizerView(VolunteerMixin, CreateView):
|
||||||
|
|
||||||
context["volunteer_registration_form"] = VolunteerRegistrationForm(self.request.POST or None)
|
context["volunteer_registration_form"] = VolunteerRegistrationForm(self.request.POST or None)
|
||||||
del context["volunteer_registration_form"].fields["email_confirmed"]
|
del context["volunteer_registration_form"].fields["email_confirmed"]
|
||||||
|
if not self.request.user.registration.is_admin:
|
||||||
|
del context["volunteer_registration_form"].fields["admin"]
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_form(self, form_class=None):
|
|
||||||
form = super().get_form(form_class)
|
|
||||||
|
|
||||||
if not self.request.user.registration.is_admin:
|
|
||||||
del form.fields["admin"]
|
|
||||||
|
|
||||||
return form
|
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
registration_form = VolunteerRegistrationForm(self.request.POST)
|
registration_form = VolunteerRegistrationForm(self.request.POST)
|
||||||
del registration_form.fields["email_confirmed"]
|
del registration_form.fields["email_confirmed"]
|
||||||
|
if not self.request.user.registration.is_admin:
|
||||||
|
del registration_form.fields["admin"]
|
||||||
|
|
||||||
if not registration_form.is_valid():
|
if not registration_form.is_valid():
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
Loading…
Reference in New Issue