workout split works
This commit is contained in:
@@ -860,20 +860,36 @@ def split_workout(r,parent,splitsecond,splitmode):
|
||||
ids = []
|
||||
|
||||
if 'keep first' in splitmode:
|
||||
if 'secondprivate' in splitmode:
|
||||
setprivate = True
|
||||
else:
|
||||
setprivate = False
|
||||
|
||||
id,message = new_workout_from_df(r,data1,
|
||||
title=parent.name+' First Part',
|
||||
parent=parent)
|
||||
parent=parent,
|
||||
setprivate=setprivate)
|
||||
messages.append(message)
|
||||
ids.append(id)
|
||||
if 'keep second' in splitmode:
|
||||
data2['cumdist'] = data2['cumdist'] - data2.ix[0,'cumdist']
|
||||
data2['distance'] = data2['distance'] - data2.ix[0,'distance']
|
||||
data2['time'] = data2['time'] - data2.ix[0,'time']
|
||||
if 'secondprivate' in splitmode:
|
||||
setprivate = True
|
||||
else:
|
||||
setprivate = False
|
||||
|
||||
dt = datetime.timedelta(seconds=splitsecond)
|
||||
|
||||
id,message = new_workout_from_df(r,data2,
|
||||
title=parent.name+' Second Part',
|
||||
parent=parent)
|
||||
parent=parent,
|
||||
setprivate=setprivate,
|
||||
dt=dt)
|
||||
messages.append(message)
|
||||
ids.append(id)
|
||||
|
||||
|
||||
if not 'keep original' in splitmode:
|
||||
if 'keep second' in splitmode or 'keep first' in splitmode:
|
||||
@@ -882,6 +898,9 @@ def split_workout(r,parent,splitsecond,splitmode):
|
||||
else:
|
||||
messages.append('That would delete your workout')
|
||||
ids.append(parent.id)
|
||||
elif 'originalprivate' in splitmode:
|
||||
parent.privacy = 'hidden'
|
||||
parent.save()
|
||||
|
||||
return ids,messages
|
||||
|
||||
@@ -890,7 +909,9 @@ def split_workout(r,parent,splitsecond,splitmode):
|
||||
# Currently there is code duplication
|
||||
def new_workout_from_df(r,df,
|
||||
title='New Workout',
|
||||
parent=None):
|
||||
parent=None,
|
||||
setprivate=False,
|
||||
dt=datetime.timedelta()):
|
||||
|
||||
message = None
|
||||
|
||||
@@ -902,7 +923,7 @@ def new_workout_from_df(r,df,
|
||||
notes=parent.notes
|
||||
summary=parent.summary
|
||||
makeprivate=parent.privacy
|
||||
startdatetime=parent.startdatetime
|
||||
startdatetime=parent.startdatetime+dt
|
||||
else:
|
||||
oarlength = 2.89
|
||||
inboard = 0.88
|
||||
@@ -912,6 +933,9 @@ def new_workout_from_df(r,df,
|
||||
makeprivate=False
|
||||
startdatetime = timezone.now()
|
||||
|
||||
if setprivate:
|
||||
makeprivate=True
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
csvfilename ='media/df_'+timestr+'.csv'
|
||||
@@ -921,7 +945,7 @@ def new_workout_from_df(r,df,
|
||||
|
||||
starttimeunix = mktime(startdatetime.utctimetuple())
|
||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
||||
print df[' ElapsedTime (sec)'].values
|
||||
|
||||
df['TimeStamp (sec)'] = df['TimeStamp (sec)']+starttimeunix
|
||||
|
||||
row = rrdata(df=df)
|
||||
|
||||
@@ -116,14 +116,26 @@ class WorkoutSplitForm(forms.Form):
|
||||
('keep original','Keep Original'),
|
||||
('keep first','Keep First Part'),
|
||||
('keep second','Keep Second Part'),
|
||||
('firstprivate','Set First Part Private'),
|
||||
('secondprivate','Set Second Part Private'),
|
||||
('originalprivate','Set Original Private'),
|
||||
)
|
||||
splittime = forms.TimeField(input_formats=['%H:%M:%S.%f','%H:%M:%S','%M:%S.%f'])
|
||||
splittime = forms.TimeField(input_formats=['%H:%M:%S.%f',
|
||||
'%H:%M:%S',
|
||||
'%H:%M:%S',
|
||||
'%M:%S.%f',
|
||||
'%M:%S',
|
||||
'%M'],
|
||||
label = 'Split Time')
|
||||
splitmode = forms.MultipleChoiceField(
|
||||
initial=['keep original',
|
||||
'keep first',
|
||||
'keep second'],
|
||||
'keep second',
|
||||
'firstprivate',
|
||||
'secondprivate'],
|
||||
label='Split Mode',
|
||||
choices=splitchoices)
|
||||
choices=splitchoices,
|
||||
widget = forms.CheckboxSelectMultiple())
|
||||
|
||||
# This form is used on the Analysis page to add a custom distance/time
|
||||
# trial and predict the pace
|
||||
|
||||
@@ -190,18 +190,30 @@
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 suffix_2 omega">
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/fusion/{{ workout.id }}/">Sensor Fusion</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Dist Metrics Plot</a>
|
||||
<a class="button blue small" href="/rowers/promembership">Split Workout</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Merge data from another source into this workout
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/split">Split Workout</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Split Workout</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Split workout into two seperate workouts
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -38,29 +38,8 @@
|
||||
|
||||
|
||||
{% localtime on %}
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th>Date/Time:</th><td>{{ workout.startdatetime }}</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>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
</tr><tr>
|
||||
<th>Public link to interactive chart</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}/interactiveplot">https://rowsandall.com/rowers/workout/{{ workout.id }}/interactiveplot</a>
|
||||
<td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endlocaltime %}
|
||||
<h1>Workout Split</h1>
|
||||
<p>Split your workout in half</p>
|
||||
|
||||
|
||||
<p>
|
||||
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id }}/split" method="post">
|
||||
<table width=100%>
|
||||
{{ form.as_table }}
|
||||
@@ -70,6 +49,22 @@
|
||||
<input class="button green" type="submit" value="Split">
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<h1>Workout Split</h1>
|
||||
<p>Split your workout in half at the given time using the form above.
|
||||
Use the chart on
|
||||
the right to find the point where you want to split.</p>
|
||||
<p>Use any of the following formats:
|
||||
<ul>
|
||||
<li>H:MM:SS.d, e.g. 1:45:00.0 for one hour and 45 minutes</li>
|
||||
<li>H:MM:SS, e.g. 1:45:00 for one hour and 45 minutes</li>
|
||||
<li>MM:SS.d, e.g. 30:00.0 for thirty minutes</li>
|
||||
<li>MM, e.g. 30 for thirty minutes</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>Warning: If you deselect, "Keep Original", the original workout
|
||||
cannot be restored afterwards.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
@@ -106,6 +101,29 @@
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
{{ thediv |safe }}
|
||||
</div>
|
||||
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th>Date/Time:</th><td>{{ workout.startdatetime }}</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>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
</tr><tr>
|
||||
<th>Public link to interactive chart</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}/interactiveplot">https://rowsandall.com/rowers/workout/{{ workout.id }}/interactiveplot</a>
|
||||
<td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endlocaltime %}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7948,8 +7948,6 @@ def workout_split_view(request,id=id):
|
||||
raise Http404("Workout doesn't exist")
|
||||
|
||||
r = getrower(request.user)
|
||||
if not checkworkoutuser(request.user,row):
|
||||
raise PermissionDenied("You are not allowed to edit this workout")
|
||||
|
||||
if request.method == 'POST':
|
||||
form = WorkoutSplitForm(request.POST)
|
||||
@@ -7965,6 +7963,9 @@ def workout_split_view(request,id=id):
|
||||
messages.info(request,message)
|
||||
|
||||
url = reverse(workouts_view)
|
||||
qdict = {'q':row.name}
|
||||
url+='?'+urllib.urlencode(qdict)
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
form = WorkoutSplitForm()
|
||||
|
||||
Reference in New Issue
Block a user