added virtual event link
This commit is contained in:
@@ -724,8 +724,24 @@ def get_countries():
|
||||
countries = tuple([(c[0],c[0]) for c in countries])
|
||||
countries = countries+(('All','All'),)
|
||||
return countries
|
||||
|
||||
|
||||
|
||||
|
||||
class VirtualRaceSelectForm(forms.Form):
|
||||
regattatypechoices = (
|
||||
('upcoming','Upcoming Races'),
|
||||
('ongoing','Ongoing Races'),
|
||||
('previous','Previous Races'),
|
||||
('my','My Races'),
|
||||
('all','All Races'),
|
||||
)
|
||||
|
||||
regattatype = forms.ChoiceField(
|
||||
label='Type',
|
||||
choices = regattatypechoices,
|
||||
initial = 'upcoming',
|
||||
)
|
||||
|
||||
country = forms.ChoiceField(
|
||||
label='Country',
|
||||
choices = get_countries()
|
||||
|
||||
@@ -425,6 +425,13 @@ def get_sessions(r,startdate=date.today(),
|
||||
|
||||
return sps
|
||||
|
||||
def get_my_session_ids(r):
|
||||
sps = PlannedSession.objects.filter(
|
||||
rower__in=[r]
|
||||
).order_by("preferreddate","startdate","enddate")
|
||||
|
||||
return [ps.id for ps in sps]
|
||||
|
||||
def get_workouts_session(r,ps):
|
||||
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
||||
|
||||
|
||||
55
rowers/templates/virtualevent.html
Normal file
55
rowers/templates/virtualevent.html
Normal file
@@ -0,0 +1,55 @@
|
||||
{% extends "base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}New Virtual Race{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="grid_12 alpha">
|
||||
|
||||
<h1>{{ race.name }}</h1>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid_12 alpha">
|
||||
<div class="grid_8 alpha">
|
||||
<h2>Race Information</h2>
|
||||
<p>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Course</th><td>{{ race.course }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Date</th><td>{{ race.startdate }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Race Window</th><td>{{ race.startdate }} {{ race.start_time }} to {{ race.enddate }} {{ race.end_time }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Results Submission Deadline</th><td>{{ race.evaluation_closure }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Organizer</th><td>{{ race.manager.first_name }} {{ race.manager.last_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Contact Email</th><td>{{ race.contact_email }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Contact Phone</th><td>{{ race.contact_phone }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_4 omega">
|
||||
<h2>Course</h2>
|
||||
{{ coursediv|safe }}
|
||||
|
||||
{{ coursescript|safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -145,6 +145,7 @@ urlpatterns = [
|
||||
url(r'^list-workouts/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_view),
|
||||
url(r'^virtualevents$',views.virtualevents_view),
|
||||
url(r'^virtualevent/create$',views.virtualevent_create_view),
|
||||
url(r'^virtualevent/(?P<id>\d+)$',views.virtualevent_view),
|
||||
url(r'^list-workouts/$',views.workouts_view),
|
||||
url(r'^list-courses/$',views.courses_view),
|
||||
url(r'^courses/upload$',views.course_upload_view),
|
||||
|
||||
@@ -13322,7 +13322,9 @@ def virtualevents_view(request):
|
||||
# default races
|
||||
races = VirtualRace.objects.filter(
|
||||
startdate__gte=datetime.date.today()
|
||||
)
|
||||
).order_by("startdate","start_time")
|
||||
|
||||
r = getrower(request.user)
|
||||
|
||||
if request.method == 'POST':
|
||||
# process form
|
||||
@@ -13330,15 +13332,38 @@ def virtualevents_view(request):
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
country = cd['country']
|
||||
regattatype = cd['regattatype']
|
||||
if country == 'All':
|
||||
countries = VirtualRace.objects.order_by('country').values_list('country').distinct()
|
||||
else:
|
||||
countries = [country]
|
||||
|
||||
races = VirtualRace.objects.filter(
|
||||
startdate__gte=datetime.date.today(),
|
||||
country__in=countries
|
||||
)
|
||||
|
||||
if regattatype == 'upcoming':
|
||||
races = VirtualRace.objects.filter(
|
||||
startdate__gte=datetime.date.today(),
|
||||
country__in=countries
|
||||
).order_by("startdate","start_time")
|
||||
elif regattatype == 'previous':
|
||||
races = VirtualRace.objects.filter(
|
||||
enddate__lt=datetime.date.today(),
|
||||
country__in=countries
|
||||
).order_by("startdate","start_time")
|
||||
elif regattatype == 'ongoing':
|
||||
races = VirtualRace.objects.filter(
|
||||
startdate__lte=datetime.date.today(),
|
||||
evaluation_closure__gte=datetime.date.today(),
|
||||
country__in=countries
|
||||
).order_by("startdate","start_time")
|
||||
elif regattatype == 'my':
|
||||
mysessions = get_my_session_ids(r)
|
||||
races = VirtualRace.objects.filter(
|
||||
id__in=mysessions,
|
||||
country__in=countries
|
||||
).order_by("startdate","start_time")
|
||||
elif regattatype == 'all':
|
||||
races = VirtualRace.objects.filter(
|
||||
country__in=countries
|
||||
).order_by("startdate","start_time")
|
||||
else:
|
||||
|
||||
form = VirtualRaceSelectForm()
|
||||
@@ -13349,6 +13374,24 @@ def virtualevents_view(request):
|
||||
}
|
||||
)
|
||||
|
||||
def virtualevent_view(request,id=0):
|
||||
r = getrower(request.user)
|
||||
|
||||
try:
|
||||
race = VirtualRace.objects.get(id=id)
|
||||
except VirtualRace.DoesNotExist:
|
||||
raise Http404("Virtual Race does not exist")
|
||||
|
||||
script,div = course_map(race.course)
|
||||
|
||||
return render(request,'virtualevent.html',
|
||||
{
|
||||
'coursescript':script,
|
||||
'coursediv':div,
|
||||
'race':race,
|
||||
'rower':r
|
||||
})
|
||||
|
||||
def virtualevent_create_view(request):
|
||||
r = getrower(request.user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user