Private
Public Access
1
0

otwsetpower

This commit is contained in:
Sander Roosendaal
2018-10-08 20:38:19 +02:00
parent 545b01e823
commit 3222ced28d
2 changed files with 87 additions and 67 deletions

View File

@@ -1,32 +1,14 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load rowerfilters %} {% load rowerfilters %}
{% block title %}Advanced Features {% endblock %} {% block title %}Advanced Features {% endblock %}
{% block content %} {% block main %}
<div id="workouts" class="grid_6 alpha">
<h1>Run OTW Power Calculations</h1>
<h1>Run OTW Power Calculations</h1> <ul class="main-content">
<div class="grid_2 alpha"> <li class="grid_4">
<p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
</p>
</div>
<div class="grid_2">
<p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/workflow">Workflow View</a>
</p>
</div>
<div class="grid_2 omega">
<p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
</p>
</div>
<div class="grid_6 alpha">
<p> <p>
For the advanced OTW power and wind correction calculation, For the advanced OTW power and wind correction calculation,
we need to know the boat type and the average weight per crew member. we need to know the boat type and the average weight per crew member.
@@ -39,6 +21,22 @@
at the cost of a slight reduction in accuracy. It is recommended at the cost of a slight reduction in accuracy. It is recommended
to keep this option selected.</p> to keep this option selected.</p>
<p>
The power calculations take wind and stream as inputs.
</p>
<p>
<a href="/rowers/workout/{{ workout.id }}/wind">Set wind strength and direction</a>
</p>
<p>
<a href="/rowers/workout/{{ workout.id }}/stream">
Set river stream strength
</a>
</p>
</li>
<li class="grid_2">
<form enctype="multipart/form-data" action="{{ formloc }}" method="post"> <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
{% if form.errors %} {% if form.errors %}
<p style="color: red;"> <p style="color: red;">
@@ -50,26 +48,27 @@
{{ form.as_table }} {{ form.as_table }}
</table> </table>
{% csrf_token %} {% csrf_token %}
</div> <div id="formbutton" class="tooltip">
<div id="formbutton" class="grid_2 prefix_2 suffix_2 tooltip">
<p><input class="button green" type="submit" value="Update & Run"></p> <p><input class="button green" type="submit" value="Update & Run"></p>
<span class="tooltiptext">Start the calculations to get power values for your row.</span> <span class="tooltiptext">Start the calculations to get power values for your row.</span>
</div> </div>
</form> </form>
</li>
</div> <li class="grid_2">
<div id="advancedplots" class="grid_6 omega">
<div> <div>
<img src="/static/img/rivercurrent.jpg" width="400"> <img src="/static/img/rivercurrent.jpg" width="400">
</div> </div>
<div> <div>
The Rowsandall Physics Department at work. The Rowsandall Physics Department at work.
</div> </div>
</div> </li>
</ul>
{% endblock %} {% endblock %}
{% block sidebar %}
{% include 'menu_workout.html' %}
{% endblock %}

View File

@@ -7129,9 +7129,10 @@ def workout_stream_view(request,id=0,message="",successmessage=""):
# Form to set average crew weight and boat type, then run power calcs # Form to set average crew weight and boat type, then run power calcs
@user_passes_test(ispromember, login_url="/",redirect_field_name=None) @user_passes_test(ispromember, login_url="/",redirect_field_name=None)
def workout_otwsetpower_view(request,id=0,message="",successmessage=""): def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
row = get_workout(id) w = get_workout(id)
r = getrower(request.user)
if (checkworkoutuser(request.user,row)==False): if (checkworkoutuser(request.user,w)==False):
message = "You are not allowed to edit this workout" message = "You are not allowed to edit this workout"
messages.error(request,message) messages.error(request,message)
url = reverse(workouts_view) url = reverse(workouts_view)
@@ -7147,13 +7148,13 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
quick_calc = form.cleaned_data['quick_calc'] quick_calc = form.cleaned_data['quick_calc']
boattype = form.cleaned_data['boattype'] boattype = form.cleaned_data['boattype']
weightvalue = form.cleaned_data['weightvalue'] weightvalue = form.cleaned_data['weightvalue']
row.boattype = boattype w.boattype = boattype
row.weightvalue = weightvalue w.weightvalue = weightvalue
row.save() w.save()
# load row data & create power/wind/bearing columns if not set # load row data & create power/wind/bearing columns if not set
f1 = row.csvfilename f1 = w.csvfilename
rowdata = rdata(f1) rowdata = rdata(f1)
if rowdata == 0: if rowdata == 0:
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
@@ -7220,13 +7221,33 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
response = HttpResponseRedirect(url) response = HttpResponseRedirect(url)
else: else:
form = AdvancedWorkoutForm(instance=row) form = AdvancedWorkoutForm(instance=w)
breadcrumbs = [
{
'url':'/rowers/list-workouts',
'name':'Workouts'
},
{
'url':get_workout_default_page(request,id),
'name': str(w.id)
},
{
'url':reverse(workout_otwsetpower_view,kwargs={'id':id}),
'name': 'OTW Power'
}
]
messages.error(request,message) messages.error(request,message)
messages.info(request,successmessage) messages.info(request,successmessage)
return render(request, return render(request,
'otwsetpower.html', 'otwsetpower.html',
{'workout':row, {'workout':w,
'rower':w,
'active':'nav-workouts',
'breadcrumbs':breadcrumbs,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'form':form, 'form':form,
}) })