1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-08-21 16:47:22 +02:00

We can only register during the first phase

This commit is contained in:
Yohann D'ANELLO
2020-11-15 01:50:12 +01:00
parent d3e18a8fbb
commit 731f8711ff
7 changed files with 112 additions and 100 deletions

View File

@@ -13,6 +13,7 @@ from django.utils.http import urlsafe_base64_decode
from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView, DetailView, RedirectView, TemplateView, UpdateView, View
from magic import Magic
from participation.models import Phase
from .forms import CoachRegistrationForm, PhotoAuthorizationForm, SignupForm, StudentRegistrationForm, UserForm
from .models import StudentRegistration
@@ -27,6 +28,15 @@ class SignupView(CreateView):
template_name = "registration/signup.html"
extra_context = dict(title=_("Sign up"))
def dispatch(self, request, *args, **kwargs):
"""
The signup view is available only during the first phase.
"""
current_phase = Phase.current_phase()
if not current_phase or current_phase.phase_number >= 2:
raise PermissionDenied(_("You can't register now."))
return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data()