Merge branch 'release/v6.87'
This commit is contained in:
+5
-6
@@ -748,9 +748,8 @@ def fetchcp(rower,theworkouts,table='cpdata'):
|
|||||||
|
|
||||||
|
|
||||||
# create a new workout from manually entered data
|
# create a new workout from manually entered data
|
||||||
def create_row_df(r,distance,duration,startdatetime,
|
def create_row_df(r,distance,duration,startdatetime,workouttype='rower'):
|
||||||
title = 'Manually added workout',notes='',
|
|
||||||
workouttype='rower'):
|
|
||||||
|
|
||||||
|
|
||||||
nr_strokes = int(distance/10.)
|
nr_strokes = int(distance/10.)
|
||||||
@@ -808,10 +807,10 @@ def create_row_df(r,distance,duration,startdatetime,
|
|||||||
row.write_csv(csvfilename, gzip = True)
|
row.write_csv(csvfilename, gzip = True)
|
||||||
|
|
||||||
id, message = save_workout_database(csvfilename, r,
|
id, message = save_workout_database(csvfilename, r,
|
||||||
title=title,
|
# title=title,
|
||||||
notes=notes,
|
# notes=notes,
|
||||||
dosmooth=False,
|
dosmooth=False,
|
||||||
workouttype=workouttype,
|
# workouttype=workouttype,
|
||||||
consistencychecks=False,
|
consistencychecks=False,
|
||||||
totaltime=totalseconds)
|
totaltime=totalseconds)
|
||||||
|
|
||||||
|
|||||||
+9
-30
@@ -1799,7 +1799,7 @@ class WorkoutForm(ModelForm):
|
|||||||
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Workout
|
model = Workout
|
||||||
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','privacy','rankingpiece']
|
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','rankingpiece']
|
||||||
widgets = {
|
widgets = {
|
||||||
'date': AdminDateWidget(),
|
'date': AdminDateWidget(),
|
||||||
'notes': forms.Textarea,
|
'notes': forms.Textarea,
|
||||||
@@ -1808,35 +1808,14 @@ class WorkoutForm(ModelForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(WorkoutForm, self).__init__(*args, **kwargs)
|
super(WorkoutForm, self).__init__(*args, **kwargs)
|
||||||
# this line to be removed
|
self.fields['private'] = forms.BooleanField(initial=False,
|
||||||
del self.fields['privacy']
|
required=False,
|
||||||
|
label='Private')
|
||||||
if self.instance.workouttype not in types.otwtypes:
|
if 'instance' in kwargs:
|
||||||
del self.fields['boattype']
|
if kwargs['instance'].privacy == 'visible':
|
||||||
|
self.fields['private'].initial = False
|
||||||
fieldorder = (
|
else:
|
||||||
'name',
|
self.fields['private'].initial = True
|
||||||
'date',
|
|
||||||
'starttime',
|
|
||||||
'timezone',
|
|
||||||
'duration',
|
|
||||||
'distance',
|
|
||||||
'workouttype',
|
|
||||||
'weightcategory',
|
|
||||||
'notes',
|
|
||||||
'rankingpiece',
|
|
||||||
'boattype'
|
|
||||||
)
|
|
||||||
|
|
||||||
fields = OrderedDict()
|
|
||||||
for key in fieldorder:
|
|
||||||
try:
|
|
||||||
fields[key] = self.fields.pop(key)
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
for key, valye in self.fields.items():
|
|
||||||
fields[key] = value
|
|
||||||
self.fields = fields
|
|
||||||
|
|
||||||
# Used for the rowing physics calculations
|
# Used for the rowing physics calculations
|
||||||
class AdvancedWorkoutForm(ModelForm):
|
class AdvancedWorkoutForm(ModelForm):
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ $( document ).ready(function() {
|
|||||||
$(this).val() == 'rower'
|
$(this).val() == 'rower'
|
||||||
|| $(this).val() == 'skierg'
|
|| $(this).val() == 'skierg'
|
||||||
|| $(this).val() == 'dynamic'
|
|| $(this).val() == 'dynamic'
|
||||||
|| $(this).val() == 'sliders'
|
|| $(this).val() == 'slides'
|
||||||
|| $(this).val() == 'paddle'
|
|| $(this).val() == 'paddle'
|
||||||
|| $(this).val() == 'snow'
|
|| $(this).val() == 'snow'
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -6,6 +6,34 @@
|
|||||||
|
|
||||||
{% get_current_timezone as TIME_ZONE %}
|
{% get_current_timezone as TIME_ZONE %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
|
||||||
|
<script type='text/javascript'
|
||||||
|
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
$( document ).ready(function() {
|
||||||
|
$('#id_workouttype').on('change', function(){
|
||||||
|
if (
|
||||||
|
$(this).val() == 'rower'
|
||||||
|
|| $(this).val() == 'skierg'
|
||||||
|
|| $(this).val() == 'dynamic'
|
||||||
|
|| $(this).val() == 'slides'
|
||||||
|
|| $(this).val() == 'paddle'
|
||||||
|
|| $(this).val() == 'snow'
|
||||||
|
) {
|
||||||
|
$('#id_boattype').toggle(false);
|
||||||
|
$('#id_boattype').val('1x');
|
||||||
|
} else {
|
||||||
|
$('#id_boattype').toggle(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#id_workouttype').change();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
<h1>Add Workout Manually</h1>
|
<h1>Add Workout Manually</h1>
|
||||||
|
|||||||
@@ -18,6 +18,27 @@
|
|||||||
<script type='text/javascript'
|
<script type='text/javascript'
|
||||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$( document ).ready(function() {
|
||||||
|
$('#id_workouttype').on('change', function(){
|
||||||
|
if (
|
||||||
|
$(this).val() == 'rower'
|
||||||
|
|| $(this).val() == 'skierg'
|
||||||
|
|| $(this).val() == 'dynamic'
|
||||||
|
|| $(this).val() == 'slides'
|
||||||
|
|| $(this).val() == 'paddle'
|
||||||
|
|| $(this).val() == 'snow'
|
||||||
|
) {
|
||||||
|
$('#id_boattype').toggle(false);
|
||||||
|
$('#id_boattype').val('1x');
|
||||||
|
} else {
|
||||||
|
$('#id_boattype').toggle(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#id_workouttype').change();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@@ -107,16 +128,7 @@
|
|||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="grid_2 prefix_2 alpha tooltip">
|
<div id="formbutton" class="grid_1 prefix_2 suffix_1 omega">
|
||||||
{% if workout.privacy == 'visible' %}
|
|
||||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/setprivate">Set Private</a>
|
|
||||||
<span class="tooltiptext">Only you can see this workout</span>
|
|
||||||
{% else %}
|
|
||||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/makepublic">Make Public</a>
|
|
||||||
<span class="tooltiptext">Make this workout visible to your teams and followers</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div id="formbutton" class="grid_1 suffix_1 omega">
|
|
||||||
<input class="button green" type="submit" value="Save">
|
<input class="button green" type="submit" value="Save">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -450,6 +450,8 @@ class DataTest(TestCase):
|
|||||||
'notes':'Aap noot \n mies',
|
'notes':'Aap noot \n mies',
|
||||||
'weightcategory':'lwt',
|
'weightcategory':'lwt',
|
||||||
'workouttype':'water',
|
'workouttype':'water',
|
||||||
|
'boattype':'1x',
|
||||||
|
'private':False,
|
||||||
}
|
}
|
||||||
form = WorkoutForm(data=form_data)
|
form = WorkoutForm(data=form_data)
|
||||||
self.assertTrue(form.is_valid())
|
self.assertTrue(form.is_valid())
|
||||||
@@ -680,6 +682,8 @@ class ViewTest(TestCase):
|
|||||||
'distance':'15000',
|
'distance':'15000',
|
||||||
'weightcategory':'hwt',
|
'weightcategory':'hwt',
|
||||||
'workouttype':'rower',
|
'workouttype':'rower',
|
||||||
|
'boattype':'1x',
|
||||||
|
'private':True,
|
||||||
'notes':'noot mies',
|
'notes':'noot mies',
|
||||||
}
|
}
|
||||||
form = WorkoutForm(data=form_data)
|
form = WorkoutForm(data=form_data)
|
||||||
|
|||||||
+27
-8
@@ -3604,6 +3604,7 @@ def addmanual_view(request):
|
|||||||
distance = form.cleaned_data['distance']
|
distance = form.cleaned_data['distance']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
thetimezone = form.cleaned_data['timezone']
|
thetimezone = form.cleaned_data['timezone']
|
||||||
|
private = form.cleaned_data['private']
|
||||||
try:
|
try:
|
||||||
boattype = request.POST['boattype']
|
boattype = request.POST['boattype']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -3617,6 +3618,11 @@ def addmanual_view(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
rankingpiece =- Workout.objects.get(id=id).rankingpiece
|
rankingpiece =- Workout.objects.get(id=id).rankingpiece
|
||||||
|
|
||||||
|
if private:
|
||||||
|
privacy = 'private'
|
||||||
|
else:
|
||||||
|
privacy = 'visible'
|
||||||
|
|
||||||
startdatetime = (str(date) + ' ' + str(starttime))
|
startdatetime = (str(date) + ' ' + str(starttime))
|
||||||
startdatetime = datetime.datetime.strptime(startdatetime,
|
startdatetime = datetime.datetime.strptime(startdatetime,
|
||||||
"%Y-%m-%d %H:%M:%S")
|
"%Y-%m-%d %H:%M:%S")
|
||||||
@@ -3628,10 +3634,10 @@ def addmanual_view(request):
|
|||||||
|
|
||||||
id,message = dataprep.create_row_df(r,
|
id,message = dataprep.create_row_df(r,
|
||||||
distance,
|
distance,
|
||||||
weightcategory,
|
# weightcategory,
|
||||||
duration,startdatetime,
|
duration,startdatetime,
|
||||||
title = name,
|
# title = name,
|
||||||
notes=notes,
|
# notes=notes,
|
||||||
workouttype=workouttype)
|
workouttype=workouttype)
|
||||||
|
|
||||||
|
|
||||||
@@ -3642,7 +3648,12 @@ def addmanual_view(request):
|
|||||||
if id:
|
if id:
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
w.rankingpiece = rankingpiece or is_ranking_piece(w)
|
w.rankingpiece = rankingpiece or is_ranking_piece(w)
|
||||||
|
w.privacy = privacy
|
||||||
|
w.weightcategory = weightcategory
|
||||||
w.notes = notes
|
w.notes = notes
|
||||||
|
w.name = name
|
||||||
|
w.workouttype = workouttype
|
||||||
|
w.boattype = boattype
|
||||||
w.save()
|
w.save()
|
||||||
messages.info(request,'New workout created')
|
messages.info(request,'New workout created')
|
||||||
|
|
||||||
@@ -7541,7 +7552,7 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
|
|||||||
def instroke_view(request,id=0):
|
def instroke_view(request,id=0):
|
||||||
row = get_workout(id)
|
row = get_workout(id)
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
# form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
# check if user is owner of this workout
|
# check if user is owner of this workout
|
||||||
|
|
||||||
@@ -7573,7 +7584,7 @@ def instroke_view(request,id=0):
|
|||||||
def workout_geeky_view(request,id=0,message="",successmessage=""):
|
def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||||
row = get_workout(id)
|
row = get_workout(id)
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
# form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
rowdata = rrdata(csvfile=row.csvfilename)
|
rowdata = rrdata(csvfile=row.csvfilename)
|
||||||
instrokemetrics = rowdata.get_instroke_columns()
|
instrokemetrics = rowdata.get_instroke_columns()
|
||||||
@@ -8131,7 +8142,7 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
|
|||||||
def workout_advanced_view(request,id=0,message="",successmessage=""):
|
def workout_advanced_view(request,id=0,message="",successmessage=""):
|
||||||
row = get_workout(id)
|
row = get_workout(id)
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
# form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
for i in g:
|
for i in g:
|
||||||
try:
|
try:
|
||||||
@@ -8851,7 +8862,7 @@ def workout_export_view(request,id=0, message="", successmessage=""):
|
|||||||
rkuserid = 0
|
rkuserid = 0
|
||||||
|
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
# form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
for i in g:
|
for i in g:
|
||||||
try:
|
try:
|
||||||
@@ -9190,6 +9201,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
weightcategory = form.cleaned_data['weightcategory']
|
weightcategory = form.cleaned_data['weightcategory']
|
||||||
duration = form.cleaned_data['duration']
|
duration = form.cleaned_data['duration']
|
||||||
distance = form.cleaned_data['distance']
|
distance = form.cleaned_data['distance']
|
||||||
|
private = form.cleaned_data['private']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
thetimezone = form.cleaned_data['timezone']
|
thetimezone = form.cleaned_data['timezone']
|
||||||
|
|
||||||
@@ -9206,6 +9218,11 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
rankingpiece =- Workout.objects.get(id=id).rankingpiece
|
rankingpiece =- Workout.objects.get(id=id).rankingpiece
|
||||||
|
|
||||||
|
if private:
|
||||||
|
privacy = 'private'
|
||||||
|
else:
|
||||||
|
privacy = 'visible'
|
||||||
|
|
||||||
startdatetime = datetime.datetime.combine(
|
startdatetime = datetime.datetime.combine(
|
||||||
date,starttime
|
date,starttime
|
||||||
)
|
)
|
||||||
@@ -10169,11 +10186,13 @@ def workout_getc2workout_view(request,c2id):
|
|||||||
distance,
|
distance,
|
||||||
duration,
|
duration,
|
||||||
startdatetime,
|
startdatetime,
|
||||||
title = 'Imported from C2',
|
# title = 'Imported from C2',
|
||||||
workouttype=workouttype)
|
workouttype=workouttype)
|
||||||
|
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
w.uploadedtoc2 = c2id
|
w.uploadedtoc2 = c2id
|
||||||
|
w.name = 'Imported from C2'
|
||||||
|
w.workouttype = 'rower'
|
||||||
w.save()
|
w.save()
|
||||||
|
|
||||||
message = "This workout does not have any stroke data associated with it. We created synthetic stroke data."
|
message = "This workout does not have any stroke data associated with it. We created synthetic stroke data."
|
||||||
|
|||||||
Reference in New Issue
Block a user