diff --git a/rowers/models.py b/rowers/models.py index 75afa570..5ef03d68 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1059,9 +1059,19 @@ class PlannedSession(models.Model): super(PlannedSession,self).save(*args, **kwargs) from django.core.validators import RegexValidator,validate_email - + +registerchoices = ( + ('windowstart','Start of Race Window'), + ('windowend','End of Race Window'), + ('deadline','Evaluation Closure Deadline'), + ('manual','Manual - select below'), + ) + class VirtualRace(PlannedSession): - has_registration = models.BooleanField(default=False) +# has_registration = models.BooleanField(default=False) + registration_form = models.CharField(max_length=100, + default='windowstart', + choices=registerchoices) registration_closure = models.DateTimeField(blank=True,null=True) evaluation_closure = models.DateTimeField(blank=True,null=True) start_time = models.TimeField(blank=True,null=True) @@ -1137,6 +1147,7 @@ class VirtualRaceForm(ModelForm): course = forms.ModelChoiceField(queryset = GeoCourse.objects, empty_label=None) registration_closure = forms.SplitDateTimeField(widget=AdminSplitDateTime(),required=False) evaluation_closure = forms.SplitDateTimeField(widget=AdminSplitDateTime(),required=True) + class Meta: model = VirtualRace @@ -1146,7 +1157,8 @@ class VirtualRaceForm(ModelForm): 'start_time', 'enddate', 'end_time', - 'has_registration', +# 'has_registration', + 'registration_form', 'registration_closure', 'evaluation_closure', 'course', diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 20c37388..847d2f26 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -473,12 +473,26 @@ def update_virtualrace(ps,cd): ps.evaluation_closure = pytz.timezone(timezone_str).localize( ps.evaluation_closure.replace(tzinfo=None) ) - try: - ps.registration_closure = pytz.timezone(timezone_str).localize( - ps.registration_closure.replace(tzinfo=None) - ) - except AttributeError: - pass + + registration_form = cd['registration_form'] + registration_closure = cd['registration_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 + + ps.registration_closure = registration_closure ps.timezone = timezone_str @@ -553,6 +567,7 @@ def race_can_resubmit(r,race): evaluation_closure = race.evaluation_closure + if timezone.now() > startdatetime and timezone.now() < evaluation_closure: is_complete,has_registered = race_rower_status(r,race) return is_complete @@ -573,11 +588,11 @@ def race_can_withdraw(r,race): ) registration_closure = race.registration_closure - if registration_closure is not None and registration_closure != '': - if timezone.now() > registration_closure: - return False - elif timezone.now() > startdatetime: - return False + if registration_closure is None or registration_closure == '': + registration_closure = startdatetime + + if timezone.now() > registration_closure: + return False elif timezone.now() > startdatetime: return False @@ -595,13 +610,11 @@ def race_can_register(r,race): ) registration_closure = race.registration_closure - if registration_closure is not None and registration_closure != '': - if timezone.now() > registration_closure: - return False - elif timezone.now() > startdatetime: - return False - elif timezone.now() > startdatetime: - return False + if registration_closure is None or registration_closure == '': + registration_closure = startdatetime + + if timezone.now() > registration_closure: + return False return True diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index dc5b7a25..954f66b4 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -23,12 +23,10 @@
As a rowsandall.com user, you can - register to take part in this event. - If the race organizer has set a registration deadline, you must - register before the deadline. Otherwise, it is sufficient to - register before the start of the race window. + register to take part in this event. Please note the registration + deadline. You must register before this deadline. You can always withdraw from participating before the registration - deadline or the start of the race window, if no registration - deadline was set. + deadline or the start of the race window, whichever is earlier.
After the start of the race window and before the submission deadline, diff --git a/rowers/views.py b/rowers/views.py index 37d09098..9eca2437 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -13576,7 +13576,7 @@ def virtualevent_create_view(request): comment = cd['comment'] course = cd['course'] name = cd['name'] - has_registration = cd['has_registration'] + registration_form = cd['registration_form'] registration_closure = cd['registration_closure'] evaluation_closure = cd['evaluation_closure'] contact_phone = cd['contact_phone'] @@ -13590,6 +13590,8 @@ def virtualevent_create_view(request): startdatetime = datetime.datetime.combine(startdate,start_time) enddatetime = datetime.datetime.combine(enddate,end_time) + print enddatetime + startdatetime = pytz.timezone(timezone_str).localize( startdatetime ) @@ -13599,15 +13601,23 @@ def virtualevent_create_view(request): evaluation_closure = pytz.timezone(timezone_str).localize( evaluation_closure.replace(tzinfo=None) ) - try: - registration_closure = pytz.timezone( - timezone_str - ).localize( - registration_closure.replace(tzinfo=None) - ) - except AttributeError: - pass - + + 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 + vs = VirtualRace( name=name, @@ -13620,7 +13630,6 @@ def virtualevent_create_view(request): comment=comment, sessiontype = 'coursetest', timezone=timezone_str, - has_registration=has_registration, evaluation_closure=evaluation_closure, registration_closure=registration_closure, contact_phone=contact_phone,