race registration rules more flexible
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@
|
||||
<tr>
|
||||
<th>Course</th><td>{{ race.course }}</td>
|
||||
</tr>
|
||||
{% if race.has_registration %}
|
||||
<tr>
|
||||
<th>Registration closure</th>
|
||||
<td>{{ race.registration_closure }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th>Date</th><td>{{ race.startdate }}</td>
|
||||
</tr>
|
||||
@@ -175,13 +173,10 @@
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
After the start of the race window and before the submission deadline,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user