Merge branch 'release/v12.51'
This commit is contained in:
+12
-2
@@ -389,18 +389,26 @@ class UploadOptionsForm(forms.Form):
|
||||
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')
|
||||
registration_closure__gt=timezone.now())
|
||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
userid = r.id)
|
||||
|
||||
registrations2 = VirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
userid = r.id,
|
||||
)
|
||||
|
||||
raceids = [r.race.id for r in registrations]
|
||||
raceids2 = [r.race.id for r in registrations2]
|
||||
|
||||
raceids = raceids+raceids2
|
||||
|
||||
races = VirtualRace.objects.filter(
|
||||
id__in=raceids
|
||||
)
|
||||
|
||||
|
||||
if races:
|
||||
self.fields['submitrace'].queryset = races
|
||||
else:
|
||||
@@ -409,6 +417,8 @@ class UploadOptionsForm(forms.Form):
|
||||
if int(raceid) in raceids:
|
||||
self.fields['submitrace'].initial = VirtualRace.objects.get(id=raceid)
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
@@ -1472,7 +1472,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
|
||||
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
||||
return result,comments,errors,0
|
||||
|
||||
if ws.count()>1 and race.sessiontype == 'test':
|
||||
if len(ws)>1 and race.sessiontype == 'test':
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors,0
|
||||
|
||||
@@ -1553,6 +1553,8 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
|
||||
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
|
||||
ws[0].id,race.course.id,record.id,splitsecond=splitsecond)
|
||||
|
||||
|
||||
|
||||
add_workouts_plannedsession(ws,race,r)
|
||||
|
||||
|
||||
|
||||
@@ -1148,6 +1148,37 @@ def handle_send_disqualification_email(
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_send_withdraw_email(
|
||||
useremail,username,reason,message, racename, **kwargs):
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
debug = True
|
||||
|
||||
subject = "Your result for {n} has been removed on rowsandall.com".format(
|
||||
n = racename
|
||||
)
|
||||
|
||||
from_email = 'Rowsandall <support@rowsandall.com>'
|
||||
|
||||
d = {
|
||||
'username':username,
|
||||
'reason':reason,
|
||||
'siteurl':siteurl,
|
||||
'message': htmlstrip(message),
|
||||
'racename':racename,
|
||||
}
|
||||
|
||||
res = send_template_email(from_email,[useremail],
|
||||
subject,
|
||||
'withdraw_email.html',
|
||||
d,**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_expired(useremail,userfirstname,userlastname,expireddate,
|
||||
**kwargs):
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
</h1>
|
||||
<p>
|
||||
Please select a reason and add a comment (mandatory).
|
||||
Pressing 'Reject' disqualifies the submitted result.
|
||||
Pressing 'Reject' removes the submitted result.
|
||||
An email will be sent to the rower. There is no "undo".
|
||||
</p>
|
||||
<p>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<i class="fas fa-file-plus fa-fw"></i> Submit Workout</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/rowers/workout/upload/">
|
||||
<a href="/rowers/workout/upload/{{ race.id }}/">
|
||||
<i class="fas fa-file-upload fa-fw"></i> Upload your Challenge result
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -313,6 +313,13 @@
|
||||
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if result.userid == request.user.rower.id and not race|is_final %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/withdrawresult/{{ result.id }}">
|
||||
Remove
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for result in dns %}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
{% extends "emailbase.html" %}
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ username }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
The result that you have submitted for the virtual challenge {{ racename }} has been
|
||||
removed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The reason for the removal was: <i>{{ reason }}</i>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You added the following explanation:
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<i>{{ message }}</i>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
You are still registered for the challenge and can submit a result.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,138 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ workout.name }} {% endblock %}
|
||||
{% block og_title %}{{ workout.name }} {% endblock %}
|
||||
{% block description %}{{ workout.name }}
|
||||
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||
{% block og_description %}{{ workout.name }}
|
||||
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||
{% if graphs1 %}
|
||||
{% endif %}
|
||||
{% for graph in graphs1 %}
|
||||
{% block og_image %}
|
||||
{% if graphs1 %}
|
||||
{% for graph in graphs %}
|
||||
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<meta property="og:image" content="http://rowsandall.com/static/img/logo_r.png" />
|
||||
<meta property="og:image:secure_url" content="https://rowsandall.com/static/img/logo_r.png" />
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block image_src %}
|
||||
{% for graph in graphs %}
|
||||
<link rel="image_src" href="/{{ graph.filename |spacetohtml }}" />
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% endfor %}
|
||||
{% block main %}
|
||||
|
||||
<h1>Do you want to withdraw this result?</h1>
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<p>
|
||||
Before you reject this challenge result, please carefully review it
|
||||
using the information below. If you still want to reject the entry,
|
||||
scroll down to the rejection form.
|
||||
</p>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th>Rower:</th><td>{{ record.username }}</td>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
<th>Name:</th><td>{{ workout.name }}</td>
|
||||
</tr><tr>
|
||||
<tr>
|
||||
<th>Date:</th><td>{{ workout.date }}</td>
|
||||
</tr><tr>
|
||||
<th>Time:</th><td>{{ workout.starttime }}</td>
|
||||
</tr><tr>
|
||||
<th>Distance:</th><td>{{ workout.distance }}m</td>
|
||||
</tr><tr>
|
||||
<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
||||
</tr><tr>
|
||||
<th>Type:</th><td>{{ workout.workouttype }}</td>
|
||||
</tr><tr>
|
||||
<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<h1>Workout Summary</h1>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
{{ workout.summary }}
|
||||
</pre>
|
||||
</p>
|
||||
</li>
|
||||
{% for graph in graphs %}
|
||||
<li>
|
||||
<a href="/rowers/graph/{{ graph.id }}/">
|
||||
<img src="/{{ graph.filename }}"
|
||||
onerror="this.src='/static/img/rowingtimer.gif'"
|
||||
alt="{{ graph.filename }}" width="120" height="100">
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% if mapdiv %}
|
||||
<li class="grid_2">
|
||||
<div class="mapdiv">
|
||||
|
||||
{{ mapdiv|safe }}
|
||||
|
||||
|
||||
{{ mapscript|safe }}
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="grid_2">
|
||||
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
|
||||
<script async="true" type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
|
||||
{{ the_div|safe }}
|
||||
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<h1>
|
||||
Yes, I want to reject this entry
|
||||
</h1>
|
||||
<p>
|
||||
Please select a reason and add a comment (mandatory).
|
||||
Pressing 'Reject' removes the submitted result.
|
||||
An email will be sent to the rower. There is no "undo".
|
||||
</p>
|
||||
<p>
|
||||
<form enctype="multipart/form-date" action="" method="post">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
{% csrf_token %}
|
||||
<input type="submit" value="Reject">
|
||||
</p>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_racing.html' %}
|
||||
{% endblock %}
|
||||
@@ -195,6 +195,8 @@ urlpatterns = [
|
||||
views.virtualevent_submit_result_view,name='virtualevent_submit_result_view'),
|
||||
re_path(r'^virtualevent/(?P<id>\d+)/disqualify/(?P<recordid>\d+)/',
|
||||
views.virtualevent_disqualify_view,name='virtualevent_disqualify_view'),
|
||||
re_path(r'^virtualevent/(?P<id>\d+)/withdrawresult/(?P<recordid>\d+)/',
|
||||
views.virtualevent_withdrawresult_view,name='virtualevent_withdrawresult_view'),
|
||||
re_path(r'^list-workouts/$',views.workouts_view,name='workouts_view'),
|
||||
re_path(r'^list-courses/$',views.courses_view,name='courses_view'),
|
||||
re_path(r'^courses/upload/$',views.course_upload_view,name='course_upload_view'),
|
||||
|
||||
+144
-1
@@ -647,7 +647,7 @@ def virtualevent_disqualify_view(request,id=0,recordid=0):
|
||||
},
|
||||
{
|
||||
'url':reverse(virtualevent_disqualify_view,
|
||||
kwargs={'raceid':raceid,
|
||||
kwargs={'id':id,
|
||||
'recordid':recordid}),
|
||||
'name': 'Disqualify Entry'
|
||||
},
|
||||
@@ -688,6 +688,149 @@ def virtualevent_disqualify_view(request,id=0,recordid=0):
|
||||
'record':record,
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def virtualevent_withdrawresult_view(request,id=0,recordid=0):
|
||||
|
||||
r = getrower(request.user)
|
||||
race = get_object_or_404(VirtualRace,pk=id)
|
||||
|
||||
|
||||
if race.sessiontype == 'race':
|
||||
recordobj = VirtualRaceResult
|
||||
else:
|
||||
recordobj = IndoorVirtualRaceResult
|
||||
|
||||
# datum moet voor race evaluation date zijn (ook in template controleren)
|
||||
|
||||
try:
|
||||
record = recordobj.objects.get(id=recordid)
|
||||
except recordobj.DoesNotExist:
|
||||
messages.error(request,"We couldn't find the record")
|
||||
|
||||
if r.id != record.userid:
|
||||
raise PermissionDenied("You are not the owner of this result")
|
||||
|
||||
if timezone.now() > race.evaluation_closure+datetime.timedelta(hours=1):
|
||||
messages.error(request,"The evaluation is already closed and the results are official")
|
||||
url = reverse('virtualevent_view',kwargs={'id':raceid})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = DisqualificationForm(request.POST)
|
||||
if form.is_valid():
|
||||
message = form.cleaned_data['message']
|
||||
reason = form.cleaned_data['reason']
|
||||
disqualifier = disqualifiers[reason]
|
||||
|
||||
r = Rower.objects.get(id=record.userid)
|
||||
name = record.username
|
||||
|
||||
job = myqueue(queue,handle_send_withdraw_email,
|
||||
r.user.email, name,
|
||||
disqualifier,message,race.name)
|
||||
|
||||
messages.info(request,"We have invalidated the result for: "+str(record))
|
||||
|
||||
record.coursecompleted = False
|
||||
record.save()
|
||||
|
||||
url = reverse('virtualevent_view',kwargs={'id':id})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
else:
|
||||
form = DisqualificationForm(request.POST)
|
||||
|
||||
workout = Workout.objects.get(id=record.workoutid)
|
||||
|
||||
g = GraphImage.objects.filter(workout=workout).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
script, div = interactive_chart(record.workoutid)
|
||||
|
||||
f1 = workout.csvfilename
|
||||
rowdata = rdata(f1)
|
||||
hascoordinates = 1
|
||||
if rowdata != 0:
|
||||
try:
|
||||
latitude = rowdata.df[' latitude']
|
||||
if not latitude.std():
|
||||
hascoordinates = 0
|
||||
except (KeyError, AttributeError):
|
||||
hascoordinates = 0
|
||||
else:
|
||||
hascoordinates = 0
|
||||
|
||||
if hascoordinates:
|
||||
mapscript, mapdiv = leaflet_chart(rowdata.df[' latitude'],
|
||||
rowdata.df[' longitude'],
|
||||
workout.name)
|
||||
else:
|
||||
mapscript = ""
|
||||
mapdiv = ""
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':reverse('virtualevents_view'),
|
||||
'name': 'Challenges'
|
||||
},
|
||||
{
|
||||
'url':reverse('virtualevent_view',
|
||||
kwargs={'id':race.id}),
|
||||
'name': race.name
|
||||
},
|
||||
{
|
||||
'url':reverse(virtualevent_disqualify_view,
|
||||
kwargs={'id':id,
|
||||
'recordid':recordid}),
|
||||
'name': 'Disqualify Entry'
|
||||
},
|
||||
]
|
||||
|
||||
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,"withdraw_view.html",
|
||||
{'workout':workout,
|
||||
'active':'nav-racing',
|
||||
'graphs':g,
|
||||
'buttons':buttons,
|
||||
'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'mapscript':mapscript,
|
||||
'mapdiv':mapdiv,
|
||||
'form':form,
|
||||
'race':race,
|
||||
'record':record,
|
||||
})
|
||||
|
||||
|
||||
def virtualevent_view(request,id=0):
|
||||
|
||||
results = []
|
||||
|
||||
@@ -195,6 +195,7 @@ from rowers.tasks import (
|
||||
handle_sendemail_unrecognized,handle_sendemailnewcomment,
|
||||
handle_sendemailsummary,
|
||||
handle_send_disqualification_email,
|
||||
handle_send_withdraw_email,
|
||||
handle_sendemailfile,
|
||||
handle_sendemailkml,
|
||||
handle_sendemailnewresponse, handle_updatedps,
|
||||
|
||||
@@ -4965,26 +4965,46 @@ def workout_upload_view(request,
|
||||
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 race.sessiontype == 'indoorrace':
|
||||
records = IndoorVirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
userid=r.id
|
||||
)
|
||||
|
||||
if result:
|
||||
messages.info(
|
||||
request,
|
||||
"We have submitted your workout to the race")
|
||||
if records:
|
||||
|
||||
for c in comments:
|
||||
messages.info(request,c)
|
||||
for er in errors:
|
||||
messages.error(request,er)
|
||||
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 race.sessiontype == 'race':
|
||||
records = VirtualRaceResult.objects.filter(
|
||||
race=race,userid=r.id
|
||||
)
|
||||
|
||||
|
||||
if records:
|
||||
result,comments,errors,jobid = add_workout_race(
|
||||
[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':
|
||||
|
||||
Reference in New Issue
Block a user