mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-02 00:28:32 +02:00
Allow admins to create users outside registration period
This commit is contained in:
@ -62,6 +62,20 @@ class SignupView(CreateView):
|
||||
|
||||
@transaction.atomic
|
||||
def form_valid(self, form):
|
||||
if not self.request.user.registration.is_admin:
|
||||
# Check that registrations are opened
|
||||
now = timezone.now()
|
||||
if now < settings.REGISTRATION_DATES['open']:
|
||||
form.add_error(None, format_lazy(_("Registrations are not opened yet. "
|
||||
"They will open on the {opening_date:%Y-%m-%d %H:%M}."),
|
||||
opening_date=settings.REGISTRATION_DATES['open']))
|
||||
elif now > settings.REGISTRATION_DATES['close']:
|
||||
form.add_error(None, format_lazy(_("Registrations for this year are closed since "
|
||||
"{closing_date:%Y-%m-%d %H:%M}."),
|
||||
closing_date=settings.REGISTRATION_DATES['close']))
|
||||
if not form.is_valid():
|
||||
return self.form_invalid(form)
|
||||
|
||||
role = form.cleaned_data["role"]
|
||||
if role == "participant":
|
||||
registration_form = StudentRegistrationForm(self.request.POST)
|
||||
|
Reference in New Issue
Block a user