Merge branch 'release/v8.63'
This commit is contained in:
+31
-1
@@ -1,6 +1,9 @@
|
||||
from django import forms
|
||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||
from rowers.models import Workout,Rower,Team,PlannedSession,GeoCourse
|
||||
from rowers.models import (
|
||||
Workout,Rower,Team,PlannedSession,GeoCourse,
|
||||
VirtualRace,VirtualRaceResult,IndoorVirtualRaceResult
|
||||
)
|
||||
from rowers.rows import validate_file_extension,must_be_csv,validate_image_extension,validate_kml
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
@@ -16,6 +19,7 @@ from utils import landingpages
|
||||
from metrics import axes
|
||||
|
||||
|
||||
|
||||
# login form
|
||||
class LoginForm(forms.Form):
|
||||
username = forms.CharField()
|
||||
@@ -254,6 +258,10 @@ class UploadOptionsForm(forms.Form):
|
||||
makeprivate = forms.BooleanField(initial=False,required=False,
|
||||
label='Make Workout Private')
|
||||
|
||||
submitrace = forms.ModelChoiceField(queryset=VirtualRace.objects.all(),
|
||||
label='Submit as Race Result',
|
||||
required=False)
|
||||
|
||||
landingpage = forms.ChoiceField(choices=nextpages,
|
||||
initial='workout_edit_view',
|
||||
label='After Upload, go to')
|
||||
@@ -261,6 +269,28 @@ class UploadOptionsForm(forms.Form):
|
||||
class Meta:
|
||||
fields = ['make_plot','plottype','upload_toc2','makeprivate']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.request = kwargs.pop('request',None)
|
||||
super(UploadOptionsForm, self).__init__(*args, **kwargs)
|
||||
r = Rower.objects.get(user=self.request.user)
|
||||
races = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now(),
|
||||
sessiontype='indoorrace')
|
||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
userid = r.id)
|
||||
|
||||
raceids = [r.race.id for r in registrations]
|
||||
|
||||
races = VirtualRace.objects.filter(
|
||||
id__in=raceids
|
||||
)
|
||||
|
||||
if races:
|
||||
self.fields['submitrace'].queryset = races
|
||||
else:
|
||||
del self.fields['submitrace']
|
||||
|
||||
# The form to indicate additional actions to be performed immediately
|
||||
# after a successful upload. This version allows the Team manager to select
|
||||
# a team member
|
||||
|
||||
+5
-1
@@ -2422,6 +2422,8 @@ class VirtualRaceResult(models.Model):
|
||||
verbose_name='Gender')
|
||||
|
||||
age = models.IntegerField(null=True)
|
||||
emailnotifications = models.BooleanField(default=True,
|
||||
verbose_name = 'Receive race notifications by email')
|
||||
|
||||
def __unicode__(self):
|
||||
rr = Rower.objects.get(id=self.userid)
|
||||
@@ -2472,6 +2474,8 @@ class IndoorVirtualRaceResult(models.Model):
|
||||
verbose_name='Gender')
|
||||
|
||||
age = models.IntegerField(null=True)
|
||||
emailnotifications = models.BooleanField(default=True,
|
||||
verbose_name = 'Receive race notifications by email')
|
||||
|
||||
def __unicode__(self):
|
||||
rr = Rower.objects.get(id=self.userid)
|
||||
@@ -2686,7 +2690,7 @@ class WorkoutForm(ModelForm):
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
).order_by("preferreddate","startdate","enddate").exclude(
|
||||
sessiontype='race')
|
||||
sessiontype__in=['race','indoorrace'])
|
||||
|
||||
if not sps:
|
||||
del self.fields['plannedsession']
|
||||
|
||||
@@ -20,7 +20,7 @@ from rowers.models import (
|
||||
Rower, Workout,Team,
|
||||
GeoCourse, TrainingMicroCycle,TrainingMesoCycle,TrainingMacroCycle,
|
||||
TrainingPlan,PlannedSession,VirtualRaceResult,CourseTestResult,
|
||||
get_course_timezone, IndoorVirtualRaceResult
|
||||
get_course_timezone, IndoorVirtualRaceResult,VirtualRace
|
||||
)
|
||||
|
||||
from rowers.courses import get_time_course
|
||||
@@ -33,6 +33,41 @@ import iso8601
|
||||
from iso8601 import ParseError
|
||||
from rowers.tasks import handle_check_race_course
|
||||
|
||||
def get_indoorraces(workout):
|
||||
races1 = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now(),
|
||||
sessiontype='indoorrace',
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
sessionmode='distance',
|
||||
sessionvalue=workout.distance)
|
||||
|
||||
|
||||
if workout.duration.second != 0 and workout.duration.microsecond != 0:
|
||||
duration = 60*workout.duration.hour+workout.duration.minute
|
||||
|
||||
|
||||
races2 = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now(),
|
||||
sessiontype='indoorrace',
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
sessionmode='time',
|
||||
sessionvalue=duration)
|
||||
|
||||
races = races1 | races2
|
||||
else:
|
||||
races = races1
|
||||
|
||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
userid=workout.user.id)
|
||||
|
||||
races = [r.race for r in registrations]
|
||||
|
||||
|
||||
return races
|
||||
|
||||
def get_todays_micro(plan,thedate=date.today()):
|
||||
thismicro = None
|
||||
|
||||
@@ -729,10 +764,11 @@ def race_can_submit(r,race):
|
||||
if is_complete == False:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
print 'pop'
|
||||
return False
|
||||
|
||||
def race_can_resubmit(r,race):
|
||||
@@ -970,6 +1006,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
|
||||
record.duration = ws[0].duration
|
||||
|
||||
|
||||
|
||||
if ws[0].weightcategory != record.weightcategory:
|
||||
errors.append('Your workout weight category did not match the weight category you registered')
|
||||
return 0,comments, errors,0
|
||||
|
||||
@@ -740,6 +740,66 @@ def handle_updatedps(useremail, workoutids, debug=False,**kwargs):
|
||||
|
||||
# send email when a breakthrough workout is uploaded
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_raceregistration(
|
||||
useremail, username, registeredname, racename, raceid, **kwargs):
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
debug = True
|
||||
|
||||
subject = "A new competitor has registered for virtual race {n}".format(
|
||||
n = racename
|
||||
)
|
||||
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
d = {
|
||||
'username':username,
|
||||
'registeredname':registeredname,
|
||||
'siteurl':siteurl,
|
||||
'racename':racename,
|
||||
'raceid':raceid,
|
||||
}
|
||||
|
||||
res = send_template_email(from_email,[useremail],
|
||||
subject,
|
||||
'raceregisteredemail.html',
|
||||
d,**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_racesubmission(
|
||||
useremail, username, registeredname, racename, raceid, **kwargs):
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
debug = True
|
||||
|
||||
subject = "A new result has been submitted for virtual race {n}".format(
|
||||
n = racename
|
||||
)
|
||||
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
d = {
|
||||
'username':username,
|
||||
'siteurl':siteurl,
|
||||
'registeredname':registeredname,
|
||||
'racename':racename,
|
||||
'raceid':raceid,
|
||||
}
|
||||
|
||||
res = send_template_email(from_email,[useremail],
|
||||
subject,
|
||||
'racesubmissionemail.html',
|
||||
d,**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_send_disqualification_email(
|
||||
useremail,username,reason,message, racename, **kwargs):
|
||||
@@ -758,6 +818,7 @@ def handle_send_disqualification_email(
|
||||
d = {
|
||||
'username':username,
|
||||
'reason':reason,
|
||||
'siteurl':siteurl,
|
||||
'message': strip_tags(message),
|
||||
'racename':racename,
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
<p>
|
||||
Unfortunately, the result that you have submitted
|
||||
for the virtual race {{ racename }}
|
||||
for the virtual race
|
||||
{{ racename }}
|
||||
has been rejected by the race organizer.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -15,15 +15,82 @@
|
||||
<i class="far fa-flag fa-fw"></i> New Indoor Race
|
||||
</a>
|
||||
</li>
|
||||
{% if race %}
|
||||
{% if reguest.user.is_anonymous %}
|
||||
<li id="race-register">
|
||||
{% if race.sessiontype == 'race' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/register">
|
||||
<i class="fas fa-user-plus fa-fw"></i> Register</a>
|
||||
{% else %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor">
|
||||
<i class="fas fa-user-plus fa-fw"></i> Register</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for button in buttons %}
|
||||
{% if button == 'registerbutton' %}
|
||||
<li>
|
||||
{% if race.sessiontype == 'race' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/register">
|
||||
<i class="fas fa-user-plus fa-fw"></i> Register</a>
|
||||
{% else %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor">
|
||||
<i class="fas fa-user-plus fa-fw"></i> Register</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if button == 'submitbutton' %}
|
||||
<li>
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">
|
||||
<i class="fas fa-file-plus fa-fw"></i> Submit Workout</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/rowers/workout/upload">
|
||||
<i class="fas fa-file-upload fa-fw"></i> Upload your race result
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/rowers/addmanual">
|
||||
<i class="fas fa-file-plus fa-fw"></i> Enter Result
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if button == 'resubmitbutton' %}
|
||||
<li>
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit New Result</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if button == 'withdrawbutton' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/withdraw">
|
||||
<i class="fas fa-user-minus fa-fw"></i> Withdraw</a>
|
||||
{% endif %}
|
||||
{% if button == 'adddisciplinebutton' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/adddiscipline">
|
||||
<i class="fas fa-users fa-fw"></i> Register New Boat
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if button == 'editbutton' %}
|
||||
<li>
|
||||
{% if race.sessiontype == 'race' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/edit"><i class="fas fa-pencil-alt fa-fw"></i> Edit Race
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/editindoor"><i class="fas fa-pencil-alt fa-fw"></i> Edit Race
|
||||
</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<li id="courses">
|
||||
<a href="/rowers/list-courses">
|
||||
<i class="fas fa-map-marked fa-fw"></i> Courses
|
||||
<i class="fas fa-route fa-fw"></i> Courses
|
||||
</a>
|
||||
</li>
|
||||
{% if course %}
|
||||
<li class="has-children" id="course">
|
||||
<input type="checkbox" name="group-course" id="group-course" checked>
|
||||
<label for="group-course"><i class="fas fa-map-marked fa-fw"></i> {{ course.name }}</label>
|
||||
<label for="group-course"><i class="fas fa-route fa-fw"></i> {{ course.name }}</label>
|
||||
<ul>
|
||||
<li id="course-view">
|
||||
<a href="/rowers/courses/{{ course.id }}">
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
{% if rower %}
|
||||
{% if race|can_register:rower %}
|
||||
<a class="white dot" href="/rowers/virtualevent/{{ race.id }}"> </a>
|
||||
{% elif race|can_submit:rower %}
|
||||
<a class="orange dot" href="/rowers/virtualevent/{{ race.id }}"> </a>
|
||||
{% elif race|race_complete:rower %}
|
||||
<a class="green dot" href="/rowers/virtualevent/{{ race.id }}"> </a>
|
||||
{% elif race|can_submit:rower %}
|
||||
<a class="orange dot" href="/rowers/virtualevent/{{ race.id }}"> </a>
|
||||
{% elif race|future_registered:rower %}
|
||||
<a class="orange dot" href="/rowers/virtualevent/{{ race.id }}"> </a>
|
||||
{% elif race|past_not_registered:rower %}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{% extends "emailbase.html" %}
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ username }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
A new competitor has registered for the race {{ racename }}: {{ registeredname }}
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
You can check race participants and results on the race page on Rowsandall:
|
||||
<a href="{{ siteurl }}/rowers/virtualevent/{{ raceid }}">{{ racename }}</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You are receiving this email because you are on the start list for this race.
|
||||
If you do not wish to receive these notifications, you can switch them off
|
||||
throught the link above.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{% extends "emailbase.html" %}
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ username }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
One of your competitors, {{ registeredname }}, has submitted a result for {{ racename }}
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
Check out the results on the race page!
|
||||
<a href="{{ siteurl }}/rowers/virtualevent/{{ raceid }}">{{ racename }}</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You are receiving this email because you are on the start list for this race.
|
||||
If you do not wish to receive these notifications, you can switch them off
|
||||
throught the link above.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -40,7 +40,11 @@
|
||||
<a class="twitter-share-button"
|
||||
href="https://twitter.com/intent/tweet"
|
||||
data-url="{{ request.build_absolute_uri }}"
|
||||
data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{ race.name }}'">Tweet</a>
|
||||
{% if race.sessiontype == 'race' %}
|
||||
data-text="@rowsandall #rowingdata Participate in virtual race '{{ race.name }}'">Tweet</a>
|
||||
{% else %}
|
||||
data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{ race.name }}'">Tweet</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
|
||||
@@ -151,7 +155,37 @@
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if button == 'submitbutton' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit Result</a>
|
||||
<table width=100% class="shortpadded">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit Workout</a>
|
||||
</td>
|
||||
<td>
|
||||
Submit a workout that is already on the site as your race result
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/rowers/upload">Upload your race result</a>
|
||||
</td>
|
||||
<td>
|
||||
Upload a new workout to the site and submit it as a result. You
|
||||
need a workout data file.
|
||||
</td>
|
||||
</tr>
|
||||
{% if race.sessiontype == 'indoorrace' %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/rowers/addmanual">Enter your race result manually</a>
|
||||
</td>
|
||||
<td>
|
||||
If you don't have a data file, enter the results
|
||||
manually. If you have a photo of the monitor with the
|
||||
result, it is recommended to add this to the workout.
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% endif %}
|
||||
{% if button == 'resubmitbutton' %}
|
||||
<p>
|
||||
@@ -283,7 +317,7 @@
|
||||
</table>
|
||||
|
||||
{% csrf_token %}
|
||||
<input class="button green" type="submit" value="Submit">
|
||||
<input type="submit" value="Submit">
|
||||
</p>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -327,6 +361,31 @@
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% for record in records %}
|
||||
{% if record.userid == request.user.rower.id %}
|
||||
{% if race.sessiontype == 'race' %}
|
||||
{% if record.emailnotifications %}
|
||||
<a href="/rowers/raceregistration/togglenotification/{{ race.id }}">
|
||||
Unsubscribe from race notifications by email
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="/rowers/raceregistration/togglenotification/{{ race.id }}">
|
||||
Subscribe to race notifications by email
|
||||
</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if record.emailnotifications %}
|
||||
<a href="/rowers/indoorraceregistration/togglenotification/{{ race.id }}">
|
||||
Unsubscribe from race notifications by email
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="/rowers/indoorraceregistration/togglenotification/{{ race.id }}">
|
||||
Subscribe to race notifications by email
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<div id="rules">
|
||||
|
||||
@@ -118,6 +118,16 @@ $('#id_workouttype').change();
|
||||
</pre>
|
||||
</p>
|
||||
</li>
|
||||
{% if indoorraces %}
|
||||
<li>
|
||||
<h1>Racing</h1>
|
||||
{% for race in indoorraces %}
|
||||
<p>
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit this to Indoor Race {{ race.name }}</a>
|
||||
</p>
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if mapdiv %}
|
||||
<li class="grid_2">
|
||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||
|
||||
@@ -144,6 +144,10 @@ urlpatterns = [
|
||||
url(r'^virtualevents$',views.virtualevents_view),
|
||||
url(r'^virtualevent/create$',views.virtualevent_create_view),
|
||||
url(r'^virtualevent/createindoor$',views.indoorvirtualevent_create_view),
|
||||
url(r'^raceregistration/togglenotification/(?P<id>\d+)/$',
|
||||
views.virtualevent_toggle_email_view),
|
||||
url(r'^indoorraceregistration/togglenotification/(?P<id>\d+)/$',
|
||||
views.indoorvirtualevent_toggle_email_view),
|
||||
url(r'^virtualevent/(?P<id>\d+)$',views.virtualevent_view),
|
||||
url(r'^virtualevent/(?P<id>\d+)/edit$',views.virtualevent_edit_view),
|
||||
url(r'^virtualevent/(?P<id>\d+)/editindoor$',views.indoorvirtualevent_edit_view),
|
||||
|
||||
+293
-2
@@ -168,6 +168,8 @@ from rowers.tasks import (
|
||||
handle_update_empower,
|
||||
handle_sendemailics,
|
||||
handle_sendemail_userdeleted,
|
||||
handle_sendemail_raceregistration,
|
||||
handle_sendemail_racesubmission,
|
||||
)
|
||||
|
||||
from scipy.signal import savgol_filter
|
||||
@@ -3458,6 +3460,12 @@ def addmanual_view(request):
|
||||
add_workouts_plannedsession([w],ps,w.user)
|
||||
|
||||
messages.info(request,'New workout created')
|
||||
|
||||
url = reverse(
|
||||
workout_edit_view,
|
||||
kwargs={'id':id}
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
return render(request,'manualadd.html',
|
||||
{'form':form,
|
||||
@@ -9977,6 +9985,8 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
row = get_workout(id)
|
||||
|
||||
indoorraces = get_indoorraces(row)
|
||||
|
||||
if (checkworkoutuser(request.user,row)==False):
|
||||
raise PermissionDenied("Access denied")
|
||||
|
||||
@@ -10169,6 +10179,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
'graphs':g,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'rower':r,
|
||||
'indoorraces':indoorraces,
|
||||
'active':'nav-workouts',
|
||||
'mapscript':mapscript,
|
||||
'mapdiv':mapdiv,
|
||||
@@ -11451,7 +11462,7 @@ def workout_upload_view(request,
|
||||
response = {}
|
||||
if request.method == 'POST':
|
||||
form = DocumentsForm(request.POST,request.FILES)
|
||||
optionsform = UploadOptionsForm(request.POST)
|
||||
optionsform = UploadOptionsForm(request.POST,request=request)
|
||||
|
||||
if form.is_valid():
|
||||
# f = request.FILES['file']
|
||||
@@ -11480,6 +11491,7 @@ def workout_upload_view(request,
|
||||
notes = form.cleaned_data['notes']
|
||||
offline = form.cleaned_data['offline']
|
||||
|
||||
race = None
|
||||
if optionsform.is_valid():
|
||||
make_plot = optionsform.cleaned_data['make_plot']
|
||||
plottype = optionsform.cleaned_data['plottype']
|
||||
@@ -11492,6 +11504,11 @@ def workout_upload_view(request,
|
||||
makeprivate = optionsform.cleaned_data['makeprivate']
|
||||
landingpage = optionsform.cleaned_data['landingpage']
|
||||
|
||||
try:
|
||||
race = optionsform.cleaned_data['submitrace']
|
||||
except KeyError:
|
||||
race = None
|
||||
|
||||
uploadoptions = {
|
||||
'makeprivate':makeprivate,
|
||||
'make_plot':make_plot,
|
||||
@@ -11677,6 +11694,28 @@ def workout_upload_view(request,
|
||||
else:
|
||||
messages.error(request,message)
|
||||
|
||||
if race and race_can_submit(r,race):
|
||||
records = IndoorVirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
userid=r.id
|
||||
)
|
||||
|
||||
if records:
|
||||
|
||||
result,comments,errors,jobid = add_workout_indoorrace(
|
||||
[w],race,r,recordid=records[0].id
|
||||
)
|
||||
|
||||
if result:
|
||||
messages.info(
|
||||
request,
|
||||
"We have submitted your workout to the race")
|
||||
|
||||
for c in comments:
|
||||
messages.info(request,c)
|
||||
for er in errors:
|
||||
messages.error(request,er)
|
||||
|
||||
|
||||
if landingpage != 'workout_upload_view':
|
||||
url = reverse(landingpage,
|
||||
@@ -11725,7 +11764,8 @@ def workout_upload_view(request,
|
||||
uploadoptions['upload_to_MapMyFitness'] = True
|
||||
|
||||
form = DocumentsForm(initial=docformoptions)
|
||||
optionsform = UploadOptionsForm(initial=uploadoptions)
|
||||
optionsform = UploadOptionsForm(initial=uploadoptions,
|
||||
request=request)
|
||||
return render(request, 'document_form.html',
|
||||
{'form':form,
|
||||
'active':'nav-workouts',
|
||||
@@ -16111,11 +16151,32 @@ def virtualevent_disqualify_view(request,raceid=0,recordid=0):
|
||||
},
|
||||
]
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
return render(request,"disqualification_view.html",
|
||||
{'workout':workout,
|
||||
'active':'nav-racing',
|
||||
'graphs':g,
|
||||
'buttons':buttons,
|
||||
'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'mapscript':mapscript,
|
||||
@@ -16453,10 +16514,31 @@ def virtualevent_addboat_view(request,id=0):
|
||||
]
|
||||
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
return render(request,'virtualeventregister.html',
|
||||
{
|
||||
'form':form,
|
||||
'buttons':buttons,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'race':race,
|
||||
'userid':r.user.id,
|
||||
@@ -16526,6 +16608,22 @@ def virtualevent_register_view(request,id=0):
|
||||
|
||||
add_rower_race(r,race)
|
||||
|
||||
otherrecords = IndoorVirtualRaceResult.objects.filter(
|
||||
race = race).exclude(userid = r.id)
|
||||
|
||||
for otherrecord in otherrecords:
|
||||
otheruser = Rower.objects.get(id=otherrecord.userid)
|
||||
othername = otheruser.user.first_name+' '+otheruser.user.last_name
|
||||
registeredname = r.user.first_name+' '+r.user.last_name
|
||||
if otherrecord.emailnotifications:
|
||||
job = myqueue(
|
||||
queue,
|
||||
handle_sendemail_raceregistration,
|
||||
otheruser.user.email, othername,
|
||||
registeredname,
|
||||
race.name,
|
||||
race.id
|
||||
)
|
||||
|
||||
|
||||
messages.info(
|
||||
@@ -16566,15 +16664,80 @@ def virtualevent_register_view(request,id=0):
|
||||
'name': 'Register'
|
||||
}
|
||||
]
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
return render(request,'virtualeventregister.html',
|
||||
{
|
||||
'form':form,
|
||||
'buttons':buttons,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'race':race,
|
||||
'userid':r.user.id,
|
||||
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def virtualevent_toggle_email_view(request,id=0):
|
||||
r = getrower(request.user)
|
||||
race = VirtualRace.objects.get(id=id)
|
||||
records = VirtualRaceResult.objects.filter(userid=r.id,race=race)
|
||||
|
||||
if True in [record.emailnotifications for record in records]:
|
||||
newsetting = False
|
||||
else:
|
||||
newsetting = True
|
||||
|
||||
for record in records:
|
||||
record.emailnotifications = newsetting
|
||||
record.save()
|
||||
|
||||
url = reverse(virtualevent_view,
|
||||
kwargs={'id':record.race.id})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def indoorvirtualevent_toggle_email_view(request,id=0):
|
||||
r = getrower(request.user)
|
||||
race = VirtualRace.objects.get(id=id)
|
||||
|
||||
records = IndoorVirtualRaceResult.objects.filter(userid=r.id,
|
||||
race=race)
|
||||
|
||||
if True in [record.emailnotifications for record in records]:
|
||||
newsetting = False
|
||||
else:
|
||||
newsetting = True
|
||||
|
||||
for record in records:
|
||||
record.emailnotifications = newsetting
|
||||
record.save()
|
||||
|
||||
url = reverse(virtualevent_view,
|
||||
kwargs={'id':record.race.id})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def indoorvirtualevent_register_view(request,id=0):
|
||||
r = getrower(request.user)
|
||||
@@ -16633,6 +16796,22 @@ def indoorvirtualevent_register_view(request,id=0):
|
||||
|
||||
add_rower_race(r,race)
|
||||
|
||||
otherrecords = IndoorVirtualRaceResult.objects.filter(
|
||||
race = race).exclude(userid = r.id)
|
||||
|
||||
for otherrecord in otherrecords:
|
||||
otheruser = Rower.objects.get(id=otherrecord.userid)
|
||||
othername = otheruser.user.first_name+' '+otheruser.user.last_name
|
||||
registeredname = r.user.first_name+' '+r.user.last_name
|
||||
if otherrecord.emailnotifications:
|
||||
job = myqueue(
|
||||
queue,
|
||||
handle_sendemail_raceregistration,
|
||||
otheruser.user.email, othername,
|
||||
registeredname,
|
||||
race.name,
|
||||
race.id
|
||||
)
|
||||
|
||||
|
||||
messages.info(
|
||||
@@ -16674,9 +16853,31 @@ def indoorvirtualevent_register_view(request,id=0):
|
||||
}
|
||||
]
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
return render(request,'virtualeventregister.html',
|
||||
{
|
||||
'form':form,
|
||||
'buttons':buttons,
|
||||
'race':race,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'userid':r.user.id,
|
||||
@@ -17024,10 +17225,32 @@ def virtualevent_edit_view(request,id=0):
|
||||
}
|
||||
]
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
return render(request,'virtualeventedit.html',
|
||||
{
|
||||
'form':racecreateform,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'buttons':buttons,
|
||||
'rower':r,
|
||||
'race':race,
|
||||
|
||||
@@ -17100,9 +17323,33 @@ def indoorvirtualevent_edit_view(request,id=0):
|
||||
'name': 'Edit'
|
||||
}
|
||||
]
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
|
||||
return render(request,'virtualeventedit.html',
|
||||
{
|
||||
'form':racecreateform,
|
||||
'buttons':buttons,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'rower':r,
|
||||
'race':race,
|
||||
@@ -17142,6 +17389,7 @@ def virtualevent_submit_result_view(request,id=0):
|
||||
race=race
|
||||
)
|
||||
|
||||
|
||||
entrychoices = []
|
||||
|
||||
for record in records:
|
||||
@@ -17235,6 +17483,25 @@ def virtualevent_submit_result_view(request,id=0):
|
||||
|
||||
messages.info(request,"We are evaluating your result. The page will reload when we're done. Your result will show up if you adhered to the course")
|
||||
|
||||
if result:
|
||||
otherrecords = resultobj.objects.filter(
|
||||
race = race).exclude(userid = r.id)
|
||||
|
||||
for otherrecord in otherrecords:
|
||||
otheruser = Rower.objects.get(id=otherrecord.userid)
|
||||
othername = otheruser.user.first_name+' '+otheruser.user.last_name
|
||||
registeredname = r.user.first_name+' '+r.user.last_name
|
||||
if otherrecord.emailnotifications:
|
||||
job = myqueue(
|
||||
queue,
|
||||
handle_sendemail_racesubmission,
|
||||
otheruser.user.email, othername,
|
||||
registeredname,
|
||||
race.name,
|
||||
race.id
|
||||
)
|
||||
|
||||
|
||||
# redirect to race page
|
||||
url = reverse(virtualevent_view,
|
||||
kwargs = {
|
||||
@@ -17264,9 +17531,33 @@ def virtualevent_submit_result_view(request,id=0):
|
||||
'name': 'Submit Result'
|
||||
}
|
||||
]
|
||||
|
||||
buttons = []
|
||||
|
||||
if not request.user.is_anonymous():
|
||||
if race_can_register(r,race):
|
||||
buttons += ['registerbutton']
|
||||
|
||||
if race_can_adddiscipline(r,race):
|
||||
buttons += ['adddisciplinebutton']
|
||||
|
||||
if race_can_submit(r,race):
|
||||
buttons += ['submitbutton']
|
||||
|
||||
if race_can_resubmit(r,race):
|
||||
buttons += ['resubmitbutton']
|
||||
|
||||
if race_can_withdraw(r,race):
|
||||
buttons += ['withdrawbutton']
|
||||
|
||||
if race_can_edit(r,race):
|
||||
buttons += ['editbutton']
|
||||
|
||||
|
||||
return render(request,'race_submit.html',
|
||||
{
|
||||
'race':race,
|
||||
'buttons':buttons,
|
||||
'workouts':ws,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'active':'nav-racing',
|
||||
|
||||
Reference in New Issue
Block a user