Private
Public Access
1
0

first form done (workout form)

This commit is contained in:
2024-01-20 16:46:55 +01:00
parent fcb296c002
commit d78f60b5b6
4 changed files with 94 additions and 32 deletions

View File

@@ -3443,6 +3443,7 @@ class PlannedSessionFormSmall(ModelForm):
boattypes = mytypes.boattypes
ergtypes = mytypes.ergtypes
# Workout
rpechoices = (
@@ -3481,9 +3482,9 @@ class Workout(models.Model):
verbose_name='Exercise/Boat Class')
workoutsource = models.CharField(max_length=100,
default='unknown')
boattype = models.CharField(choices=boattypes, max_length=50,
boattype = models.CharField(choices=boattypes+ergtypes, max_length=50,
default='1x',
verbose_name='Boat Type')
verbose_name='Boat/Rower Type')
boatbrand = models.CharField(choices=boatbrands, max_length=50,
default='', verbose_name='Boat Brand')
adaptiveclass = models.CharField(choices=adaptivetypes, max_length=50,

View File

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

View File

@@ -24,36 +24,86 @@
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
</script>
<script type='test/javascript' src='/static/js/boattypes.js'></script>
<script>
$( document ).ready(function() {
$('#id_workouttype').on('change', function(){
if (
$(this).val() == 'water'
|| $(this).val() == 'coastal'
|| $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat'
) {
$('#id_boattype').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');
}
$( 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').change();
});
</script>
$('#id_workouttype').on('change', function(){
if (
$(this).val() == 'water'
|| $(this).val() == 'coastal'
|| $(this).val() == 'c-boat'
|| $(this).val() == 'churchboat'
) {
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 %}
{% block main %}

Binary file not shown.