Private
Public Access
1
0

Merge branch 'feature/types' into develop

This commit is contained in:
2024-01-24 16:10:48 +01:00
18 changed files with 900 additions and 430 deletions

View File

@@ -1076,7 +1076,7 @@ def checkbreakthrough(w, r):
# Processes painsled CSV file to database # Processes painsled CSV file to database
def save_workout_database(f2, r, dosmooth=True, workouttype='rower', def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
boattype='1x', boattype='static',
adaptiveclass='None', adaptiveclass='None',
weightcategory='hwt', weightcategory='hwt',
dosummary=True, title='Workout', dosummary=True, title='Workout',
@@ -1366,7 +1366,7 @@ def new_workout_from_file(r, f2,
workouttype='rower', workouttype='rower',
workoutsource=None, workoutsource=None,
title='Workout', title='Workout',
boattype='1x', boattype='static',
rpe=-1, rpe=-1,
makeprivate=False, makeprivate=False,
startdatetime='', startdatetime='',
@@ -1552,7 +1552,7 @@ def new_workout_from_file(r, f2,
def new_workout_from_df(r, df, def new_workout_from_df(r, df,
title='New Workout', title='New Workout',
workoutsource='unknown', workoutsource='unknown',
boattype='1x', boattype='static',
workouttype='rower', workouttype='rower',
parent=None, parent=None,
workoutid='', workoutid='',

View File

@@ -1111,6 +1111,7 @@ class PowerIntervalUpdateForm(forms.Form):
boattypes = mytypes.boattypes boattypes = mytypes.boattypes
ergtypes = mytypes.ergtypes
workouttypes = mytypes.workouttypes workouttypes = mytypes.workouttypes
ww = list(workouttypes) ww = list(workouttypes)
ww.append(tuple(('all', 'All'))) ww.append(tuple(('all', 'All')))
@@ -1119,7 +1120,7 @@ workouttypes = tuple(ww)
class DataFrameColumnsForm(forms.Form): class DataFrameColumnsForm(forms.Form):
cols = ['ftime', 'cumdist', 'fpace', 'spm', cols = ['ftime', 'cumdist', 'fpace', 'spm',
'hr', 'power', 'driveenergy', 'drivelength', 'averageforce', 'hr', 'grpower', 'driveenergy', 'drivelength', 'averageforce',
'peakforce', 'distance', 'drivespeed', 'workoutstate', 'peakforce', 'distance', 'drivespeed', 'workoutstate',
'catch', 'finish', 'peakforceangle', 'wash', 'slip', 'rhythm', 'catch', 'finish', 'peakforceangle', 'wash', 'slip', 'rhythm',
'effectiveangle', 'totalangle', 'distanceperstroke', 'velo'] 'effectiveangle', 'totalangle', 'distanceperstroke', 'velo']
@@ -1143,7 +1144,7 @@ class AnalysisOptionsForm(forms.Form):
modality = forms.ChoiceField(choices=workouttypes, modality = forms.ChoiceField(choices=workouttypes,
label='Workout Type', label='Workout Type',
initial='all') initial='all')
waterboattype = forms.MultipleChoiceField(choices=boattypes, waterboattype = forms.MultipleChoiceField(choices=boattypes+ergtypes,
label='Water Boat Type', label='Water Boat Type',
initial=mytypes.waterboattype) initial=mytypes.waterboattype)
@@ -1156,7 +1157,7 @@ class TrendFlexModalForm(forms.Form):
modality = forms.ChoiceField(choices=workouttypes, modality = forms.ChoiceField(choices=workouttypes,
label='Workout Type', label='Workout Type',
initial='all') initial='all')
waterboattype = forms.MultipleChoiceField(choices=boattypes, waterboattype = forms.MultipleChoiceField(choices=boattypes+ergtypes,
label='Water Boat Type', label='Water Boat Type',
initial=mytypes.waterboattype) initial=mytypes.waterboattype)

View File

@@ -3443,6 +3443,7 @@ class PlannedSessionFormSmall(ModelForm):
boattypes = mytypes.boattypes boattypes = mytypes.boattypes
ergtypes = mytypes.ergtypes
# Workout # Workout
rpechoices = ( rpechoices = (
@@ -3481,9 +3482,9 @@ class Workout(models.Model):
verbose_name='Exercise/Boat Class') verbose_name='Exercise/Boat Class')
workoutsource = models.CharField(max_length=100, workoutsource = models.CharField(max_length=100,
default='unknown') default='unknown')
boattype = models.CharField(choices=boattypes, max_length=50, boattype = models.CharField(choices=boattypes+ergtypes, max_length=50,
default='1x', default='1x',
verbose_name='Boat Type') verbose_name='Boat/Rower Type')
boatbrand = models.CharField(choices=boatbrands, max_length=50, boatbrand = models.CharField(choices=boatbrands, max_length=50,
default='', verbose_name='Boat Brand') default='', verbose_name='Boat Brand')
adaptiveclass = models.CharField(choices=adaptivetypes, max_length=50, adaptiveclass = models.CharField(choices=adaptivetypes, max_length=50,
@@ -3568,6 +3569,11 @@ class Workout(models.Model):
if self.timezone == 'tzutc()': if self.timezone == 'tzutc()':
self.timezone = 'UTC' # pragma: no cover 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) super(Workout, self).save(*args, **kwargs)
def __str__(self): def __str__(self):
@@ -3581,7 +3587,7 @@ class Workout(models.Model):
boattype = self.boattype boattype = self.boattype
workouttype = self.workouttype workouttype = self.workouttype
if workouttype != 'water': if workouttype not in ['water','rower']:
try: try:
stri = u'{d} {n} {dist}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format( stri = u'{d} {n} {dist}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format(
d=date.strftime('%Y-%m-%d'), d=date.strftime('%Y-%m-%d'),

View File

@@ -8,8 +8,8 @@ workouttypes_ordered = collections.OrderedDict({
'rower': 'Indoor Rower', 'rower': 'Indoor Rower',
'skierg': 'Ski Erg', 'skierg': 'Ski Erg',
'bikeerg': 'Bike Erg', 'bikeerg': 'Bike Erg',
'dynamic': 'Dynamic Indoor Rower', # 'dynamic': 'Dynamic Indoor Rower',
'slides': 'Indoor Rower on Slides', # 'slides': 'Indoor Rower on Slides',
'paddle': 'Paddle Adapter', 'paddle': 'Paddle Adapter',
'snow': 'On-snow', 'snow': 'On-snow',
'coastal': 'Coastal', 'coastal': 'Coastal',
@@ -340,8 +340,6 @@ otwtypes = (
otetypes = ( otetypes = (
'rower', 'rower',
'dynamic',
'slides'
) )
rowtypes = ( rowtypes = (
@@ -432,6 +430,17 @@ boattypes = (
('8x+', '8x+ (octuple scull)'), ('8x+', '8x+ (octuple scull)'),
) )
ergtypes = (
('static','Concept2 static'),
('dynamic','Concept2 dynamic'),
('slides', 'Concept2 slides'),
('rp3','RP3'),
('waterrower','Water Rower'),
('other','Other Indoor Rower'),
)
adaptivetypes = ( adaptivetypes = (
('None', 'Open'), ('None', 'Open'),
('PR1', 'PR1 (Arms and Shoulders)'), ('PR1', 'PR1 (Arms and Shoulders)'),

View File

@@ -0,0 +1,4 @@
UPDATE rowers_workout
SET workouttype = 'rower', boattype = 'dynamic'
WHERE workouttype = 'dynamic';

View File

@@ -3354,8 +3354,8 @@ def handle_rp3_async_workout(userid, rp3token, rp3id, startdatetime, max_attempt
'secret': UPLOAD_SERVICE_SECRET, 'secret': UPLOAD_SERVICE_SECRET,
'user': userid, 'user': userid,
'file': filename, 'file': filename,
'workouttype': 'dynamic', 'workouttype': 'rower',
'boattype': '1x', 'boattype': 'rp3',
'rp3id': int(rp3id), 'rp3id': int(rp3id),
'startdatetime': startdatetime, 'startdatetime': startdatetime,
'timezone': timezone, 'timezone': timezone,
@@ -3552,7 +3552,12 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec,
# rest_time = 0 # rest_time = 0
distance = distance+rest_distance distance = distance+rest_distance
c2id = data['id'] c2id = data['id']
if data['type'] in ['rower','dynamic','slides']:
workouttype = 'rower'
boattype = data['type']
else:
workouttype = data['type'] workouttype = data['type']
boattype = '1x'
# verified = data['verified'] # verified = data['verified']
# weightclass = data['weight_class'] # weightclass = data['weight_class']
@@ -3696,7 +3701,7 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec,
'file': csvfilename, 'file': csvfilename,
'title': title, 'title': title,
'workouttype': workouttype, 'workouttype': workouttype,
'boattype': '1x', 'boattype': boattype,
'c2id': c2id, 'c2id': c2id,
'startdatetime': startdatetime.isoformat(), 'startdatetime': startdatetime.isoformat(),
'timezone': str(timezone) 'timezone': str(timezone)

View File

@@ -65,9 +65,33 @@
deleteText: '<div><p>&nbsp;</p></div><div>remove</div>' deleteText: '<div><p>&nbsp;</p></div><div>remove</div>'
}); });
</script> </script>
<script> <script>
$( document ).ready(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)',
}
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(){ $('#id_workouttype').on('change', function(){
if ( if (
$(this).val() == 'water' $(this).val() == 'water'
@@ -75,11 +99,46 @@ $( document ).ready(function() {
|| $(this).val() == 'c-boat' || $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat' || $(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 { } 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').toggle(false);
$('#id_boattype').val('1x'); $('#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(); $('#id_workouttype').change();

View File

@@ -66,6 +66,31 @@
</script> </script>
<script> <script>
$( document ).ready(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)',
}
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(){ $('#id_workouttype').on('change', function(){
if ( if (
$(this).val() == 'water' $(this).val() == 'water'
@@ -73,11 +98,46 @@ $( document ).ready(function() {
|| $(this).val() == 'c-boat' || $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat' || $(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 { } 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').toggle(false);
$('#id_boattype').val('1x'); $('#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(); $('#id_workouttype').change();

View File

@@ -11,8 +11,6 @@
<script type='text/javascript' <script type='text/javascript'
src='https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js'> src='https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js'>
</script> </script>
<script>
</script>
{% endblock %} {% endblock %}
{% block main %} {% block main %}
@@ -83,6 +81,31 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script> <script>
$( document ).ready(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)',
}
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(){ $('#id_workouttype').on('change', function(){
if ( if (
$(this).val() == 'water' $(this).val() == 'water'
@@ -90,15 +113,50 @@ $( document ).ready(function() {
|| $(this).val() == 'c-boat' || $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat' || $(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 { } 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').toggle(false);
$('#id_boattype').val('1x'); $('#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(); $('#id_workouttype').change();
}); });
</script> </script>
<script> <script>

View File

@@ -14,6 +14,31 @@
</script> </script>
<script> <script>
$( document ).ready(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)',
}
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(){ $('#id_workouttype').on('change', function(){
if ( if (
$(this).val() == 'water' $(this).val() == 'water'
@@ -21,11 +46,47 @@ $( document ).ready(function() {
|| $(this).val() == 'c-boat' || $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat' || $(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 { } 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').toggle(false);
$('#id_boattype').val('1x'); $('#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(); $('#id_workouttype').change();
}); });

View File

@@ -77,6 +77,31 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script> <script>
$( document ).ready(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)',
}
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(){ $('#id_workouttype').on('change', function(){
if ( if (
$(this).val() == 'water' $(this).val() == 'water'
@@ -84,14 +109,49 @@ $( document ).ready(function() {
|| $(this).val() == 'c-boat' || $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat' || $(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 { } 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').toggle(false);
$('#id_boattype').val('1x'); $('#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(); $('#id_workouttype').change();
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -20,6 +20,30 @@
// Get the form fields and hidden div // Get the form fields and hidden div
var modality = $("#id_modality"); var modality = $("#id_modality");
var hidden = $("#id_waterboattype"); var hidden = $("#id_waterboattype");
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',
}
// Hide the fields. // Hide the fields.
@@ -30,6 +54,20 @@
if (modality.val() == 'water') { if (modality.val() == 'water') {
hidden.show(); hidden.show();
var $el = $('#id_waterboattype');
$el.empty();
$.each(boattypes, function(key,value) {
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
});
$el.toggle(true);
} else if (modality.val() == 'rower') {
hidden.show();
var $el = $('#id_waterboattype');
$el.empty();
$.each(ergtypes, function(key,value) {
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
});
$el.toggle(true);
} }
@@ -44,6 +82,24 @@
if (otwtypes.includes(Value)) { if (otwtypes.includes(Value)) {
// Show the hidden fields. // Show the hidden fields.
hidden.show(); hidden.show();
var $el = $('#id_waterboattype');
var $label = $("label[for='"+$el.attr('id') + "']")
$el.empty();
$.each(boattypes, function(key,value) {
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
});
$label.text("Water Boat Type")
$el.toggle(true);
} else if (Value == 'rower') {
hidden.show();
var $el = $('#id_waterboattype');
var $label = $("label[for='"+$el.attr('id') + "']")
$el.empty();
$.each(ergtypes, function(key,value) {
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
});
$label.text("Erg Boat Type")
$el.toggle(true);
} else { } else {
// Make sure that the hidden fields are indeed // Make sure that the hidden fields are indeed
// hidden. // hidden.

View File

@@ -24,9 +24,34 @@
<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 type='test/javascript' src='/static/js/boattypes.js'></script>
<script> <script>
$( document ).ready(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)',
}
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(){ $('#id_workouttype').on('change', function(){
if ( if (
$(this).val() == 'water' $(this).val() == 'water'
@@ -34,8 +59,33 @@ $('#id_workouttype').on('change', function(){
|| $(this).val() == 'c-boat' || $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat' || $(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 { } 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').toggle(false);
$('#id_boattype').val('1x'); $('#id_boattype').val('1x');
} }

View File

@@ -16,50 +16,85 @@
</script> </script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<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 ergtypes = {
var modality = $("#id_modality"); 'static': 'Concept2 static',
var hidden = $("#id_waterboattype"); 'dynamic': 'Concept2 dynamic',
'slides': 'Concept2 slides',
'rp3': 'RP3',
'waterrower': 'Water Rower',
'other': 'Other Indoor Rower',
}
$('#id_modality').on('change', function(){
// Hide the fields. if (
// Use JS to do this in case the user doesn't have JS $(this).val() == 'water'
// enabled. || $(this).val() == 'coastal'
|| $(this).val() == 'c-boat'
hidden.hide(); || $(this).val() == 'churchboat'
) {
var $el = $('#id_waterboattype');
$el.empty();
// Setup an event listener for when the state of the $.each(boattypes, function(key,value) {
// checkbox changes. if ( key == '{{ workout.boattype }}') {
modality.change(function() { $el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
// 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();
} else { } else {
// Make sure that the hidden fields are indeed $el.append($("<option></option").attr("value", key).text(value));
// 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.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(){ $(document).ready(function(){
console.log('kill parents') console.log('kill parents')
$("#id_killparents").change(function() { $("#id_killparents").change(function() {

Binary file not shown.

View File

@@ -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 from rowers.rower_rules import is_promember

View File

@@ -100,6 +100,11 @@ def analysis_new(request,
waterboattype = mytypes.waterboattype waterboattype = mytypes.waterboattype
try:
waterboattype = options['waterboattype']
except KeyError:
pass
if request.method == 'POST': if request.method == 'POST':
thediv = get_call() thediv = get_call()
dateform = DateRangeForm(request.POST) dateform = DateRangeForm(request.POST)
@@ -122,7 +127,7 @@ def analysis_new(request,
modalities = [m[0] for m in mytypes.workouttypes] modalities = [m[0] for m in mytypes.workouttypes]
else: # pragma: no cover else: # pragma: no cover
modalities = [modality] modalities = [modality]
if modality != 'water': if modality not in ['water','rower']:
waterboattype = [b[0] for b in mytypes.boattypes] waterboattype = [b[0] for b in mytypes.boattypes]
options['modalities'] = modalities options['modalities'] = modalities
@@ -160,6 +165,9 @@ def analysis_new(request,
for b in mytypes.boattypes: for b in mytypes.boattypes:
if b[0] not in waterboattype: # pragma: no cover if b[0] not in waterboattype: # pragma: no cover
negtypes.append(b[0]) 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()) startdate = datetime.datetime.combine(startdate, datetime.time())
enddate = datetime.datetime.combine(enddate, datetime.time(23, 59, 59)) enddate = datetime.datetime.combine(enddate, datetime.time(23, 59, 59))
@@ -179,11 +187,6 @@ def analysis_new(request,
except (ValueError, AttributeError): # pragma: no cover except (ValueError, AttributeError): # pragma: no cover
pass pass
negtypes = []
for b in mytypes.boattypes:
if b[0] not in waterboattype: # pragma: no cover
negtypes.append(b[0])
rankingtypes = [False,True] rankingtypes = [False,True]
if ranking: if ranking:
rankingtypes = [True] rankingtypes = [True]

View File

@@ -1219,6 +1219,9 @@ def workouts_join_select(request,
for b in mytypes.boattypes: for b in mytypes.boattypes:
if b[0] not in waterboattype: if b[0] not in waterboattype:
negtypes.append(b[0]) 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()) startdate = datetime.datetime.combine(startdate, datetime.time())
enddate = datetime.datetime.combine(enddate, datetime.time(23, 59, 59)) enddate = datetime.datetime.combine(enddate, datetime.time(23, 59, 59))