mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 01:32:05 +01:00 
			
		
		
		
	Fix registration dates test
This commit is contained in:
		@@ -7,8 +7,6 @@ from django.contrib.auth.forms import UserCreationForm
 | 
				
			|||||||
from django.contrib.auth.models import User
 | 
					from django.contrib.auth.models import User
 | 
				
			||||||
from django.core.exceptions import ValidationError
 | 
					from django.core.exceptions import ValidationError
 | 
				
			||||||
from django.forms import FileInput
 | 
					from django.forms import FileInput
 | 
				
			||||||
from django.utils import timezone
 | 
					 | 
				
			||||||
from django.utils.text import format_lazy
 | 
					 | 
				
			||||||
from django.utils.translation import gettext_lazy as _
 | 
					from django.utils.translation import gettext_lazy as _
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import CoachRegistration, ParticipantRegistration, Payment, \
 | 
					from .models import CoachRegistration, ParticipantRegistration, Payment, \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ from django.http import FileResponse, Http404
 | 
				
			|||||||
from django.shortcuts import redirect, resolve_url
 | 
					from django.shortcuts import redirect, resolve_url
 | 
				
			||||||
from django.template.loader import render_to_string
 | 
					from django.template.loader import render_to_string
 | 
				
			||||||
from django.urls import reverse_lazy
 | 
					from django.urls import reverse_lazy
 | 
				
			||||||
from django.utils import translation
 | 
					from django.utils import timezone, translation
 | 
				
			||||||
from django.utils.crypto import get_random_string
 | 
					from django.utils.crypto import get_random_string
 | 
				
			||||||
from django.utils.http import urlsafe_base64_decode
 | 
					from django.utils.http import urlsafe_base64_decode
 | 
				
			||||||
from django.utils.text import format_lazy
 | 
					from django.utils.text import format_lazy
 | 
				
			||||||
@@ -60,9 +60,10 @@ class SignupView(CreateView):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return context
 | 
					        return context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @transaction.atomic
 | 
					    def get_form(self, form_class=None):
 | 
				
			||||||
    def form_valid(self, form):
 | 
					        form = super().get_form(form_class)
 | 
				
			||||||
        if not self.request.user.registration.is_admin:
 | 
					        if self.request.method in ("POST", "PUT") \
 | 
				
			||||||
 | 
					                and (not self.request.user.is_authenticated or not self.request.user.registration.is_admin):
 | 
				
			||||||
            # Check that registrations are opened
 | 
					            # Check that registrations are opened
 | 
				
			||||||
            now = timezone.now()
 | 
					            now = timezone.now()
 | 
				
			||||||
            if now < settings.REGISTRATION_DATES['open']:
 | 
					            if now < settings.REGISTRATION_DATES['open']:
 | 
				
			||||||
@@ -73,9 +74,10 @@ class SignupView(CreateView):
 | 
				
			|||||||
                form.add_error(None, format_lazy(_("Registrations for this year are closed since "
 | 
					                form.add_error(None, format_lazy(_("Registrations for this year are closed since "
 | 
				
			||||||
                                                   "{closing_date:%Y-%m-%d %H:%M}."),
 | 
					                                                   "{closing_date:%Y-%m-%d %H:%M}."),
 | 
				
			||||||
                                                 closing_date=settings.REGISTRATION_DATES['close']))
 | 
					                                                 closing_date=settings.REGISTRATION_DATES['close']))
 | 
				
			||||||
            if not form.is_valid():
 | 
					        return form
 | 
				
			||||||
                return self.form_invalid(form)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @transaction.atomic
 | 
				
			||||||
 | 
					    def form_valid(self, form):
 | 
				
			||||||
        role = form.cleaned_data["role"]
 | 
					        role = form.cleaned_data["role"]
 | 
				
			||||||
        if role == "participant":
 | 
					        if role == "participant":
 | 
				
			||||||
            registration_form = StudentRegistrationForm(self.request.POST)
 | 
					            registration_form = StudentRegistrationForm(self.request.POST)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user