Private
Public Access
1
0

race registration rules more flexible

This commit is contained in:
Sander Roosendaal
2018-05-08 07:45:15 +02:00
parent 4475255480
commit dda47d04e5
4 changed files with 69 additions and 40 deletions

View File

@@ -1059,9 +1059,19 @@ class PlannedSession(models.Model):
super(PlannedSession,self).save(*args, **kwargs) super(PlannedSession,self).save(*args, **kwargs)
from django.core.validators import RegexValidator,validate_email 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): 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) registration_closure = models.DateTimeField(blank=True,null=True)
evaluation_closure = models.DateTimeField(blank=True,null=True) evaluation_closure = models.DateTimeField(blank=True,null=True)
start_time = models.TimeField(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) course = forms.ModelChoiceField(queryset = GeoCourse.objects, empty_label=None)
registration_closure = forms.SplitDateTimeField(widget=AdminSplitDateTime(),required=False) registration_closure = forms.SplitDateTimeField(widget=AdminSplitDateTime(),required=False)
evaluation_closure = forms.SplitDateTimeField(widget=AdminSplitDateTime(),required=True) evaluation_closure = forms.SplitDateTimeField(widget=AdminSplitDateTime(),required=True)
class Meta: class Meta:
model = VirtualRace model = VirtualRace
@@ -1146,7 +1157,8 @@ class VirtualRaceForm(ModelForm):
'start_time', 'start_time',
'enddate', 'enddate',
'end_time', 'end_time',
'has_registration', # 'has_registration',
'registration_form',
'registration_closure', 'registration_closure',
'evaluation_closure', 'evaluation_closure',
'course', 'course',

View File

@@ -473,12 +473,26 @@ def update_virtualrace(ps,cd):
ps.evaluation_closure = pytz.timezone(timezone_str).localize( ps.evaluation_closure = pytz.timezone(timezone_str).localize(
ps.evaluation_closure.replace(tzinfo=None) ps.evaluation_closure.replace(tzinfo=None)
) )
try:
ps.registration_closure = pytz.timezone(timezone_str).localize( registration_form = cd['registration_form']
ps.registration_closure.replace(tzinfo=None) registration_closure = cd['registration_closure']
) if registration_form == 'manual':
except AttributeError: try:
pass 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 ps.timezone = timezone_str
@@ -553,6 +567,7 @@ def race_can_resubmit(r,race):
evaluation_closure = race.evaluation_closure evaluation_closure = race.evaluation_closure
if timezone.now() > startdatetime and timezone.now() < evaluation_closure: if timezone.now() > startdatetime and timezone.now() < evaluation_closure:
is_complete,has_registered = race_rower_status(r,race) is_complete,has_registered = race_rower_status(r,race)
return is_complete return is_complete
@@ -573,11 +588,11 @@ def race_can_withdraw(r,race):
) )
registration_closure = race.registration_closure registration_closure = race.registration_closure
if registration_closure is not None and registration_closure != '': if registration_closure is None or registration_closure == '':
if timezone.now() > registration_closure: registration_closure = startdatetime
return False
elif timezone.now() > startdatetime: if timezone.now() > registration_closure:
return False return False
elif timezone.now() > startdatetime: elif timezone.now() > startdatetime:
return False return False
@@ -595,13 +610,11 @@ def race_can_register(r,race):
) )
registration_closure = race.registration_closure registration_closure = race.registration_closure
if registration_closure is not None and registration_closure != '': if registration_closure is None or registration_closure == '':
if timezone.now() > registration_closure: registration_closure = startdatetime
return False
elif timezone.now() > startdatetime: if timezone.now() > registration_closure:
return False return False
elif timezone.now() > startdatetime:
return False
return True return True

View File

@@ -23,12 +23,10 @@
<tr> <tr>
<th>Course</th><td>{{ race.course }}</td> <th>Course</th><td>{{ race.course }}</td>
</tr> </tr>
{% if race.has_registration %}
<tr> <tr>
<th>Registration closure</th> <th>Registration closure</th>
<td>{{ race.registration_closure }}</td> <td>{{ race.registration_closure }}</td>
</tr> </tr>
{% endif %}
<tr> <tr>
<th>Date</th><td>{{ race.startdate }}</td> <th>Date</th><td>{{ race.startdate }}</td>
</tr> </tr>
@@ -175,13 +173,10 @@
</p> </p>
<p> <p>
As a rowsandall.com user, you can As a rowsandall.com user, you can
register to take part in this event. register to take part in this event. Please note the registration
If the race organizer has set a registration deadline, you must deadline. You must register before this deadline.
register before the deadline. Otherwise, it is sufficient to
register before the start of the race window.
You can always withdraw from participating before the registration You can always withdraw from participating before the registration
deadline or the start of the race window, if no registration deadline or the start of the race window, whichever is earlier.
deadline was set.
</p> </p>
<p> <p>
After the start of the race window and before the submission deadline, After the start of the race window and before the submission deadline,

View File

@@ -13576,7 +13576,7 @@ def virtualevent_create_view(request):
comment = cd['comment'] comment = cd['comment']
course = cd['course'] course = cd['course']
name = cd['name'] name = cd['name']
has_registration = cd['has_registration'] registration_form = cd['registration_form']
registration_closure = cd['registration_closure'] registration_closure = cd['registration_closure']
evaluation_closure = cd['evaluation_closure'] evaluation_closure = cd['evaluation_closure']
contact_phone = cd['contact_phone'] contact_phone = cd['contact_phone']
@@ -13590,6 +13590,8 @@ def virtualevent_create_view(request):
startdatetime = datetime.datetime.combine(startdate,start_time) startdatetime = datetime.datetime.combine(startdate,start_time)
enddatetime = datetime.datetime.combine(enddate,end_time) enddatetime = datetime.datetime.combine(enddate,end_time)
print enddatetime
startdatetime = pytz.timezone(timezone_str).localize( startdatetime = pytz.timezone(timezone_str).localize(
startdatetime startdatetime
) )
@@ -13599,15 +13601,23 @@ def virtualevent_create_view(request):
evaluation_closure = pytz.timezone(timezone_str).localize( evaluation_closure = pytz.timezone(timezone_str).localize(
evaluation_closure.replace(tzinfo=None) evaluation_closure.replace(tzinfo=None)
) )
try:
registration_closure = pytz.timezone( if registration_form == 'manual':
timezone_str try:
).localize( registration_closure = pytz.timezone(
registration_closure.replace(tzinfo=None) timezone_str
) ).localize(
except AttributeError: registration_closure.replace(tzinfo=None)
pass )
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( vs = VirtualRace(
name=name, name=name,
@@ -13620,7 +13630,6 @@ def virtualevent_create_view(request):
comment=comment, comment=comment,
sessiontype = 'coursetest', sessiontype = 'coursetest',
timezone=timezone_str, timezone=timezone_str,
has_registration=has_registration,
evaluation_closure=evaluation_closure, evaluation_closure=evaluation_closure,
registration_closure=registration_closure, registration_closure=registration_closure,
contact_phone=contact_phone, contact_phone=contact_phone,