hopefully completing types features
This commit is contained in:
@@ -1076,7 +1076,7 @@ def checkbreakthrough(w, r):
|
||||
|
||||
# Processes painsled CSV file to database
|
||||
def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
boattype='1x',
|
||||
boattype='static',
|
||||
adaptiveclass='None',
|
||||
weightcategory='hwt',
|
||||
dosummary=True, title='Workout',
|
||||
@@ -1366,7 +1366,7 @@ def new_workout_from_file(r, f2,
|
||||
workouttype='rower',
|
||||
workoutsource=None,
|
||||
title='Workout',
|
||||
boattype='1x',
|
||||
boattype='static',
|
||||
rpe=-1,
|
||||
makeprivate=False,
|
||||
startdatetime='',
|
||||
@@ -1552,7 +1552,7 @@ def new_workout_from_file(r, f2,
|
||||
def new_workout_from_df(r, df,
|
||||
title='New Workout',
|
||||
workoutsource='unknown',
|
||||
boattype='1x',
|
||||
boattype='static',
|
||||
workouttype='rower',
|
||||
parent=None,
|
||||
workoutid='',
|
||||
|
||||
@@ -1120,7 +1120,7 @@ workouttypes = tuple(ww)
|
||||
|
||||
class DataFrameColumnsForm(forms.Form):
|
||||
cols = ['ftime', 'cumdist', 'fpace', 'spm',
|
||||
'hr', 'power', 'driveenergy', 'drivelength', 'averageforce',
|
||||
'hr', 'grpower', 'driveenergy', 'drivelength', 'averageforce',
|
||||
'peakforce', 'distance', 'drivespeed', 'workoutstate',
|
||||
'catch', 'finish', 'peakforceangle', 'wash', 'slip', 'rhythm',
|
||||
'effectiveangle', 'totalangle', 'distanceperstroke', 'velo']
|
||||
@@ -1157,7 +1157,7 @@ class TrendFlexModalForm(forms.Form):
|
||||
modality = forms.ChoiceField(choices=workouttypes,
|
||||
label='Workout Type',
|
||||
initial='all')
|
||||
waterboattype = forms.MultipleChoiceField(choices=boattypes,
|
||||
waterboattype = forms.MultipleChoiceField(choices=boattypes+ergtypes,
|
||||
label='Water Boat Type',
|
||||
initial=mytypes.waterboattype)
|
||||
|
||||
|
||||
@@ -3569,6 +3569,11 @@ class Workout(models.Model):
|
||||
if self.timezone == 'tzutc()':
|
||||
self.timezone = 'UTC' # pragma: no cover
|
||||
|
||||
if self.workouttype in mytypes.otwtypes and self.boattype in mytypes.ergtypes:
|
||||
self.boattype = '1x'
|
||||
elif self.workouttype in mytypes.otetypes and self.boattype in mytypes.boattypes:
|
||||
self.boattype = 'static'
|
||||
|
||||
super(Workout, self).save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -340,8 +340,6 @@ otwtypes = (
|
||||
|
||||
otetypes = (
|
||||
'rower',
|
||||
'dynamic',
|
||||
'slides'
|
||||
)
|
||||
|
||||
rowtypes = (
|
||||
|
||||
@@ -65,9 +65,33 @@
|
||||
deleteText: '<div><p> </p></div><div>remove</div>'
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
var boattypes = {
|
||||
'1x': '1x (single)',
|
||||
'2x': '2x (double)',
|
||||
'2x+': '2x+ (coxed double)',
|
||||
'2-': '2- (pair)',
|
||||
'2+': '2+ (coxed pair)',
|
||||
'3x+': '3x+ (coxed triple)',
|
||||
'3x-': '3x- (triple)',
|
||||
'4x': '4x (quad)',
|
||||
'4x+': '4x+ (coxed quad)',
|
||||
'4-': '4- (four)',
|
||||
'4+': '4+ (coxed four)',
|
||||
'8+': '8+ (eight)',
|
||||
'8x+': '8x+ (octuple scull)',
|
||||
}
|
||||
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
$('#id_workouttype').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'water'
|
||||
@@ -75,11 +99,46 @@ $( document ).ready(function() {
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
$('#id_boattype').toggle(true);
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(boattypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
|
||||
}
|
||||
else if (
|
||||
$(this).val() == 'rower'
|
||||
) {
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(ergtypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
}
|
||||
else {
|
||||
$('#id_boattype').toggle(false);
|
||||
$('#id_boattype').val('1x');
|
||||
}
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'slides'
|
||||
) {
|
||||
$('#id_dragfactor').toggle(true);
|
||||
} else {
|
||||
$('#id_dragfactor').toggle(false);
|
||||
$('#id_dragfactor').val('0');
|
||||
}
|
||||
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
|
||||
@@ -66,6 +66,31 @@
|
||||
</script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
var boattypes = {
|
||||
'1x': '1x (single)',
|
||||
'2x': '2x (double)',
|
||||
'2x+': '2x+ (coxed double)',
|
||||
'2-': '2- (pair)',
|
||||
'2+': '2+ (coxed pair)',
|
||||
'3x+': '3x+ (coxed triple)',
|
||||
'3x-': '3x- (triple)',
|
||||
'4x': '4x (quad)',
|
||||
'4x+': '4x+ (coxed quad)',
|
||||
'4-': '4- (four)',
|
||||
'4+': '4+ (coxed four)',
|
||||
'8+': '8+ (eight)',
|
||||
'8x+': '8x+ (octuple scull)',
|
||||
}
|
||||
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
$('#id_workouttype').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'water'
|
||||
@@ -73,11 +98,46 @@ $( document ).ready(function() {
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
$('#id_boattype').toggle(true);
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(boattypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
|
||||
}
|
||||
else if (
|
||||
$(this).val() == 'rower'
|
||||
) {
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(ergtypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
}
|
||||
else {
|
||||
$('#id_boattype').toggle(false);
|
||||
$('#id_boattype').val('1x');
|
||||
}
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'slides'
|
||||
) {
|
||||
$('#id_dragfactor').toggle(true);
|
||||
} else {
|
||||
$('#id_dragfactor').toggle(false);
|
||||
$('#id_dragfactor').val('0');
|
||||
}
|
||||
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js'>
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
@@ -83,6 +81,31 @@
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
var boattypes = {
|
||||
'1x': '1x (single)',
|
||||
'2x': '2x (double)',
|
||||
'2x+': '2x+ (coxed double)',
|
||||
'2-': '2- (pair)',
|
||||
'2+': '2+ (coxed pair)',
|
||||
'3x+': '3x+ (coxed triple)',
|
||||
'3x-': '3x- (triple)',
|
||||
'4x': '4x (quad)',
|
||||
'4x+': '4x+ (coxed quad)',
|
||||
'4-': '4- (four)',
|
||||
'4+': '4+ (coxed four)',
|
||||
'8+': '8+ (eight)',
|
||||
'8x+': '8x+ (octuple scull)',
|
||||
}
|
||||
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
$('#id_workouttype').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'water'
|
||||
@@ -90,15 +113,50 @@ $( document ).ready(function() {
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
$('#id_boattype').toggle(true);
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(boattypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
|
||||
}
|
||||
else if (
|
||||
$(this).val() == 'rower'
|
||||
) {
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(ergtypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
}
|
||||
else {
|
||||
$('#id_boattype').toggle(false);
|
||||
$('#id_boattype').val('1x');
|
||||
}
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'slides'
|
||||
) {
|
||||
$('#id_dragfactor').toggle(true);
|
||||
} else {
|
||||
$('#id_dragfactor').toggle(false);
|
||||
$('#id_dragfactor').val('0');
|
||||
}
|
||||
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -77,6 +77,31 @@
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
var boattypes = {
|
||||
'1x': '1x (single)',
|
||||
'2x': '2x (double)',
|
||||
'2x+': '2x+ (coxed double)',
|
||||
'2-': '2- (pair)',
|
||||
'2+': '2+ (coxed pair)',
|
||||
'3x+': '3x+ (coxed triple)',
|
||||
'3x-': '3x- (triple)',
|
||||
'4x': '4x (quad)',
|
||||
'4x+': '4x+ (coxed quad)',
|
||||
'4-': '4- (four)',
|
||||
'4+': '4+ (coxed four)',
|
||||
'8+': '8+ (eight)',
|
||||
'8x+': '8x+ (octuple scull)',
|
||||
}
|
||||
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
$('#id_workouttype').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'water'
|
||||
@@ -84,14 +109,49 @@ $( document ).ready(function() {
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
$('#id_boattype').toggle(true);
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(boattypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
|
||||
}
|
||||
else if (
|
||||
$(this).val() == 'rower'
|
||||
) {
|
||||
var $el = $('#id_boattype');
|
||||
$el.empty();
|
||||
$.each(ergtypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
}
|
||||
else {
|
||||
$('#id_boattype').toggle(false);
|
||||
$('#id_boattype').val('1x');
|
||||
}
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'slides'
|
||||
) {
|
||||
$('#id_dragfactor').toggle(true);
|
||||
} else {
|
||||
$('#id_dragfactor').toggle(false);
|
||||
$('#id_dragfactor').val('0');
|
||||
}
|
||||
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -16,50 +16,85 @@
|
||||
</script>
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$( document ).ready(function() {
|
||||
var boattypes = {
|
||||
'1x': '1x (single)',
|
||||
'2x': '2x (double)',
|
||||
'2x+': '2x+ (coxed double)',
|
||||
'2-': '2- (pair)',
|
||||
'2+': '2+ (coxed pair)',
|
||||
'3x+': '3x+ (coxed triple)',
|
||||
'3x-': '3x- (triple)',
|
||||
'4x': '4x (quad)',
|
||||
'4x+': '4x+ (coxed quad)',
|
||||
'4-': '4- (four)',
|
||||
'4+': '4+ (coxed four)',
|
||||
'8+': '8+ (eight)',
|
||||
'8x+': '8x+ (octuple scull)',
|
||||
}
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var modality = $("#id_modality");
|
||||
var hidden = $("#id_waterboattype");
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
|
||||
// Hide the fields.
|
||||
// Use JS to do this in case the user doesn't have JS
|
||||
// enabled.
|
||||
|
||||
hidden.hide();
|
||||
|
||||
|
||||
|
||||
// Setup an event listener for when the state of the
|
||||
// checkbox changes.
|
||||
modality.change(function() {
|
||||
// Check to see if the checkbox is checked.
|
||||
// If it is, show the fields and populate the input.
|
||||
// If not, hide the fields.
|
||||
var Value = modality.val();
|
||||
if (Value=='water') {
|
||||
// Show the hidden fields.
|
||||
hidden.show();
|
||||
$('#id_modality').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'water'
|
||||
|| $(this).val() == 'coastal'
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
var $el = $('#id_waterboattype');
|
||||
$el.empty();
|
||||
$.each(boattypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
// Make sure that the hidden fields are indeed
|
||||
// hidden.
|
||||
hidden.hide();
|
||||
|
||||
// You may also want to clear the value of the
|
||||
// hidden fields here. Just in case somebody
|
||||
// shows the fields, enters data to them and then
|
||||
// unticks the checkbox.
|
||||
//
|
||||
// This would do the job:
|
||||
//
|
||||
// $("#hidden_field").val("");
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
|
||||
}
|
||||
else if (
|
||||
$(this).val() == 'rower'
|
||||
) {
|
||||
var $el = $('#id_waterboattype');
|
||||
$el.empty();
|
||||
$.each(ergtypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
}
|
||||
else {
|
||||
$('#id_waterboattype').toggle(false);
|
||||
$('#id_waterboattype').val('1x');
|
||||
}
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'slides'
|
||||
) {
|
||||
$('#id_dragfactor').toggle(true);
|
||||
} else {
|
||||
$('#id_dragfactor').toggle(false);
|
||||
$('#id_dragfactor').val('0');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#id_modality').change();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
console.log('kill parents')
|
||||
$("#id_killparents").change(function() {
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
from rowers.mytypes import workouttypes, boattypes, otwtypes, workoutsources, workouttypes_ordered
|
||||
from rowers.mytypes import workouttypes, boattypes, ergtypes, otwtypes, workoutsources, workouttypes_ordered
|
||||
|
||||
from rowers.rower_rules import is_promember
|
||||
|
||||
|
||||
@@ -1219,6 +1219,9 @@ def workouts_join_select(request,
|
||||
for b in mytypes.boattypes:
|
||||
if b[0] not in waterboattype:
|
||||
negtypes.append(b[0])
|
||||
for b in mytypes.ergtypes:
|
||||
if b[0] not in waterboattype: # pragma: no cover
|
||||
negtypes.append(b[0])
|
||||
|
||||
startdate = datetime.datetime.combine(startdate, datetime.time())
|
||||
enddate = datetime.datetime.combine(enddate, datetime.time(23, 59, 59))
|
||||
|
||||
Reference in New Issue
Block a user