diff --git a/rowers/models.py b/rowers/models.py index d6811a12..b7497c72 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1394,9 +1394,9 @@ class VirtualRaceForm(ModelForm): enddatetime ) + registration_closure = cd['registration_closure'] - if startdatetime > enddatetime: - raise forms.ValidationError("The Start of the Race Window should be before the End of the Race Window") + registration_form = cd['registration_form'] try: evaluation_closure = cd['evaluation_closure'] @@ -1404,6 +1404,31 @@ class VirtualRaceForm(ModelForm): evaluation_closure = enddatetime+datetime.timedelta(days=1) cd['evaluation_closure'] = evaluation_closure + if registration_form == 'manual': + try: + registration_closure = pytz.timezone( + timezone_str + ).localize( + registration_closure.replace(tzinfo=None) + ) + except AttributeError: + registration_closure = startdatetime + elif registration_form == 'windowstart': + registration_closure = startdatetime + elif registration_form == 'windowend': + registration_closure = enddatetime + else: + registration_closure = evaluation_closure + + + if registration_closure <= timezone.now(): + raise forms.ValidationError("Registration Closure cannot be in the past") + + + if startdatetime > enddatetime: + raise forms.ValidationError("The Start of the Race Window should be before the End of the Race Window") + + if cd['evaluation_closure'] <= enddatetime: raise forms.ValidationError("Evaluation closure deadline should be after the Race Window closes")