Merge branch 'feature/types' into develop
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='',
|
||||
|
||||
@@ -1111,6 +1111,7 @@ class PowerIntervalUpdateForm(forms.Form):
|
||||
|
||||
|
||||
boattypes = mytypes.boattypes
|
||||
ergtypes = mytypes.ergtypes
|
||||
workouttypes = mytypes.workouttypes
|
||||
ww = list(workouttypes)
|
||||
ww.append(tuple(('all', 'All')))
|
||||
@@ -1119,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']
|
||||
@@ -1143,7 +1144,7 @@ class AnalysisOptionsForm(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)
|
||||
|
||||
@@ -1156,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)
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -3568,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):
|
||||
@@ -3581,7 +3587,7 @@ class Workout(models.Model):
|
||||
boattype = self.boattype
|
||||
workouttype = self.workouttype
|
||||
|
||||
if workouttype != 'water':
|
||||
if workouttype not in ['water','rower']:
|
||||
try:
|
||||
stri = u'{d} {n} {dist}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format(
|
||||
d=date.strftime('%Y-%m-%d'),
|
||||
|
||||
@@ -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',
|
||||
@@ -340,8 +340,6 @@ otwtypes = (
|
||||
|
||||
otetypes = (
|
||||
'rower',
|
||||
'dynamic',
|
||||
'slides'
|
||||
)
|
||||
|
||||
rowtypes = (
|
||||
@@ -432,6 +430,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)'),
|
||||
|
||||
4
rowers/sqlcode/boattypes.sql
Normal file
4
rowers/sqlcode/boattypes.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
UPDATE rowers_workout
|
||||
SET workouttype = 'rower', boattype = 'dynamic'
|
||||
WHERE workouttype = 'dynamic';
|
||||
|
||||
@@ -3354,8 +3354,8 @@ def handle_rp3_async_workout(userid, rp3token, rp3id, startdatetime, max_attempt
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': userid,
|
||||
'file': filename,
|
||||
'workouttype': 'dynamic',
|
||||
'boattype': '1x',
|
||||
'workouttype': 'rower',
|
||||
'boattype': 'rp3',
|
||||
'rp3id': int(rp3id),
|
||||
'startdatetime': startdatetime,
|
||||
'timezone': timezone,
|
||||
@@ -3552,7 +3552,12 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec,
|
||||
# rest_time = 0
|
||||
distance = distance+rest_distance
|
||||
c2id = data['id']
|
||||
workouttype = data['type']
|
||||
if data['type'] in ['rower','dynamic','slides']:
|
||||
workouttype = 'rower'
|
||||
boattype = data['type']
|
||||
else:
|
||||
workouttype = data['type']
|
||||
boattype = '1x'
|
||||
# verified = data['verified']
|
||||
|
||||
# weightclass = data['weight_class']
|
||||
@@ -3696,7 +3701,7 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec,
|
||||
'file': csvfilename,
|
||||
'title': title,
|
||||
'workouttype': workouttype,
|
||||
'boattype': '1x',
|
||||
'boattype': boattype,
|
||||
'c2id': c2id,
|
||||
'startdatetime': startdatetime.isoformat(),
|
||||
'timezone': str(timezone)
|
||||
|
||||
@@ -65,26 +65,85 @@
|
||||
deleteText: '<div><p> </p></div><div>remove</div>'
|
||||
});
|
||||
</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');
|
||||
}
|
||||
$( 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 %}
|
||||
|
||||
|
||||
|
||||
@@ -63,26 +63,86 @@
|
||||
addText: '<div> </div><div>add filter</div>',
|
||||
deleteText: '<div><p> </p></div><div>remove</div>'
|
||||
});
|
||||
</script>
|
||||
</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');
|
||||
}
|
||||
$( 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 %}
|
||||
|
||||
|
||||
|
||||
@@ -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 %}
|
||||
@@ -80,244 +78,304 @@
|
||||
|
||||
{% block scripts %}
|
||||
|
||||
<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>
|
||||
$( 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');
|
||||
}
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
});
|
||||
$( 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',
|
||||
}
|
||||
|
||||
</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>
|
||||
|
||||
<script>
|
||||
var td = new FormData();
|
||||
var formdatasetok = false;
|
||||
try {
|
||||
<script>
|
||||
var td = new FormData();
|
||||
var formdatasetok = false;
|
||||
try {
|
||||
td.set('aap','noot');
|
||||
formdatasetok = true;
|
||||
console.log('FormData.set OK');
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
console.log('FormData.set not OK');
|
||||
formdatasetok = false;
|
||||
console.log('FormData.set not OK');
|
||||
formdatasetok = false;
|
||||
}
|
||||
|
||||
if (!formdatasetok) {
|
||||
|
||||
if (!formdatasetok) {
|
||||
$("#id_dropregion").remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (formdatasetok) {
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
|
||||
console.log("CSRF token",csrftoken);
|
||||
|
||||
function csrfSafeMethod(method) {
|
||||
// these HTTP methods do not require CSRF protection
|
||||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||
}
|
||||
$.ajaxSetup({
|
||||
beforeSend: function(xhr, settings) {
|
||||
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("Loading dropper");
|
||||
jQuery.event.props.push('dataTransfer');
|
||||
|
||||
$(window).on('dragenter', function() {
|
||||
$("#id_drop-files").css("background-color","#E9E9E4");
|
||||
$("#id_dropregion").addClass("watermark").removeClass("invisible");})
|
||||
|
||||
$(window).on('dragleave', function() {
|
||||
$("#id_drop-files").css("background-color","#FFFFFF");
|
||||
$("#id_dropregion").removeClass("watermark").addClass("invisible");})
|
||||
|
||||
var frm = $("#file_form");
|
||||
|
||||
if( window.FormData === undefined ) {
|
||||
console.log('no formdata');
|
||||
alert("No FormData");
|
||||
} else {
|
||||
console.log('we have formdata');
|
||||
}
|
||||
|
||||
var data = new FormData(frm[0]);
|
||||
|
||||
$('#id_file').on('change', function(evt) {
|
||||
var f = this.files[0];
|
||||
console.log(f);
|
||||
var istcx = false;
|
||||
var isgzip = false;
|
||||
var size1 = 10485760;
|
||||
var size2 = 2097152;
|
||||
if ((/\.(tcx|TCX)/i).test(f.name)) {
|
||||
istcx = true;
|
||||
console.log('tcx');
|
||||
if ((/\.(gz|GZ)/i).test(f.name)) {
|
||||
isgzip = true;
|
||||
console.log('gzip');
|
||||
size1 /= 5;
|
||||
size2 /= 5;
|
||||
}
|
||||
}
|
||||
console.log(size1)
|
||||
console.log(size2)
|
||||
if (f.size > size1) {
|
||||
alert("File Size must be smaller than 10 MB");
|
||||
this.value = null;
|
||||
} else {
|
||||
|
||||
if (f.size > size2) {
|
||||
$('#id_offline').val('True');
|
||||
$('#id_offline').prop('checked','True');
|
||||
data.set($('#id_offline').attr('name'),$('#id_offline').prop('checked'));
|
||||
console.log("Set offline to True");
|
||||
$('#extra_message').text('Because of the large size, we recommend to use background processing. You will receive email when it is done.');
|
||||
$('#extra_message').addClass('message');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('input').each(function( i ) {
|
||||
$(this).change(function() {
|
||||
if ($(this).attr('type') == 'checkbox') {
|
||||
data.set($(this).attr('name'),$(this).prop('checked'));
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).prop('checked'));
|
||||
} else {
|
||||
data.set($(this).attr('name'),$(this).val());
|
||||
if ($(this).attr('id') == 'id_file') {
|
||||
data.set("file",this.files[0]);
|
||||
}
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).val());
|
||||
};
|
||||
});});
|
||||
|
||||
$('textarea').each(function( i ) {
|
||||
$(this).change(function() {
|
||||
data.set($(this).attr('name'),$(this).val());
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).val());
|
||||
});});
|
||||
|
||||
$('select').each(function( i ) {
|
||||
console.log($(this).attr('name'),$(this).val());
|
||||
$(this).change(function() {
|
||||
data.set($(this).attr('name'),$(this).val());
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).val());
|
||||
});
|
||||
});
|
||||
|
||||
frm.submit(function() {
|
||||
console.log("Form submission");
|
||||
$(data.values()).each(function(value) {
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
$("#id_main").replaceWith(
|
||||
'<div id="id_waiting"><img src="/static/img/rowingtimer.gif" width="60" height="50" style="width:60px">'
|
||||
);
|
||||
$.ajax({
|
||||
data: data,
|
||||
type: $(this).attr('method'),
|
||||
url: '/rowers/workout/upload/',
|
||||
contentType: false,
|
||||
processData: false,
|
||||
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
|
||||
console.log("CSRF token",csrftoken);
|
||||
|
||||
function csrfSafeMethod(method) {
|
||||
// these HTTP methods do not require CSRF protection
|
||||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||
}
|
||||
$.ajaxSetup({
|
||||
beforeSend: function(xhr, settings) {
|
||||
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("Loading dropper");
|
||||
jQuery.event.props.push('dataTransfer');
|
||||
|
||||
$(window).on('dragenter', function() {
|
||||
$("#id_drop-files").css("background-color","#E9E9E4");
|
||||
$("#id_dropregion").addClass("watermark").removeClass("invisible");})
|
||||
|
||||
$(window).on('dragleave', function() {
|
||||
$("#id_drop-files").css("background-color","#FFFFFF");
|
||||
$("#id_dropregion").removeClass("watermark").addClass("invisible");})
|
||||
|
||||
var frm = $("#file_form");
|
||||
|
||||
if( window.FormData === undefined ) {
|
||||
console.log('no formdata');
|
||||
alert("No FormData");
|
||||
} else {
|
||||
console.log('we have formdata');
|
||||
}
|
||||
|
||||
var data = new FormData(frm[0]);
|
||||
|
||||
$('#id_file').on('change', function(evt) {
|
||||
var f = this.files[0];
|
||||
console.log(f);
|
||||
var istcx = false;
|
||||
var isgzip = false;
|
||||
var size1 = 10485760;
|
||||
var size2 = 2097152;
|
||||
if ((/\.(tcx|TCX)/i).test(f.name)) {
|
||||
istcx = true;
|
||||
console.log('tcx');
|
||||
if ((/\.(gz|GZ)/i).test(f.name)) {
|
||||
isgzip = true;
|
||||
console.log('gzip');
|
||||
size1 /= 5;
|
||||
size2 /= 5;
|
||||
}
|
||||
}
|
||||
console.log(size1)
|
||||
console.log(size2)
|
||||
if (f.size > size1) {
|
||||
alert("File Size must be smaller than 10 MB");
|
||||
this.value = null;
|
||||
} else {
|
||||
|
||||
if (f.size > size2) {
|
||||
$('#id_offline').val('True');
|
||||
$('#id_offline').prop('checked','True');
|
||||
data.set($('#id_offline').attr('name'),$('#id_offline').prop('checked'));
|
||||
console.log("Set offline to True");
|
||||
$('#extra_message').text('Because of the large size, we recommend to use background processing. You will receive email when it is done.');
|
||||
$('#extra_message').addClass('message');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('input').each(function( i ) {
|
||||
$(this).change(function() {
|
||||
if ($(this).attr('type') == 'checkbox') {
|
||||
data.set($(this).attr('name'),$(this).prop('checked'));
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).prop('checked'));
|
||||
} else {
|
||||
data.set($(this).attr('name'),$(this).val());
|
||||
if ($(this).attr('id') == 'id_file') {
|
||||
data.set("file",this.files[0]);
|
||||
}
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).val());
|
||||
};
|
||||
});});
|
||||
|
||||
$('textarea').each(function( i ) {
|
||||
$(this).change(function() {
|
||||
data.set($(this).attr('name'),$(this).val());
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).val());
|
||||
});});
|
||||
|
||||
$('select').each(function( i ) {
|
||||
console.log($(this).attr('name'),$(this).val());
|
||||
$(this).change(function() {
|
||||
data.set($(this).attr('name'),$(this).val());
|
||||
console.log($(this).attr('id'),$(this).attr('name'),$(this).val());
|
||||
});
|
||||
});
|
||||
|
||||
frm.submit(function() {
|
||||
console.log("Form submission");
|
||||
$(data.values()).each(function(value) {
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
$("#id_main").replaceWith(
|
||||
'<div id="id_waiting"><img src="/static/img/rowingtimer.gif" width="60" height="50" style="width:60px">'
|
||||
);
|
||||
$.ajax({
|
||||
data: data,
|
||||
type: $(this).attr('method'),
|
||||
url: '/rowers/workout/upload/',
|
||||
contentType: false,
|
||||
processData: false,
|
||||
error: function(result) {
|
||||
$("#id_waiting").replaceWith(
|
||||
$("#id_waiting").replaceWith(
|
||||
'<div id="id_failed" class="grid_12 alpha message">Your upload failed</div>'
|
||||
);
|
||||
);
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
location.reload();
|
||||
},1000);
|
||||
},
|
||||
success: function(result) {
|
||||
console.log('got something back');
|
||||
console.log(result);
|
||||
if (result.result == 1) {
|
||||
window.location.href = result.url;
|
||||
} else {
|
||||
console.log(result," reloading");
|
||||
location.reload();
|
||||
};
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#id_drop-files').bind({
|
||||
drop: function(e) {
|
||||
e.preventDefault();
|
||||
console.log("you dropped something");
|
||||
var files = e.dataTransfer.files;
|
||||
console.log(files[0]);
|
||||
|
||||
var f = files[0];
|
||||
var istcx = false;
|
||||
var isgzip = false;
|
||||
var size1 = 10485760;
|
||||
var size2 = 1048576;
|
||||
if ((/\.(tcx|TCX)/i).test(f.name)) {
|
||||
istcx = true;
|
||||
console.log('tcx');
|
||||
if ((/\.(gz|GZ)/i).test(f.name)) {
|
||||
isgzip = true;
|
||||
console.log('gzip');
|
||||
size1 /= 5;
|
||||
size2 /= 5;
|
||||
}
|
||||
}
|
||||
console.log(f);
|
||||
console.log(size1)
|
||||
console.log(size2)
|
||||
if (f.size > size1) {
|
||||
alert("File Size must be smaller than 10 MB");
|
||||
$("#id_file").value = 0;
|
||||
return false;
|
||||
}
|
||||
if (f.size > size2) {
|
||||
success: function(result) {
|
||||
console.log('got something back');
|
||||
console.log(result);
|
||||
if (result.result == 1) {
|
||||
window.location.href = result.url;
|
||||
} else {
|
||||
console.log(result," reloading");
|
||||
location.reload();
|
||||
};
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#id_drop-files').bind({
|
||||
drop: function(e) {
|
||||
e.preventDefault();
|
||||
console.log("you dropped something");
|
||||
var files = e.dataTransfer.files;
|
||||
console.log(files[0]);
|
||||
|
||||
var f = files[0];
|
||||
var istcx = false;
|
||||
var isgzip = false;
|
||||
var size1 = 10485760;
|
||||
var size2 = 1048576;
|
||||
if ((/\.(tcx|TCX)/i).test(f.name)) {
|
||||
istcx = true;
|
||||
console.log('tcx');
|
||||
if ((/\.(gz|GZ)/i).test(f.name)) {
|
||||
isgzip = true;
|
||||
console.log('gzip');
|
||||
size1 /= 5;
|
||||
size2 /= 5;
|
||||
}
|
||||
}
|
||||
console.log(f);
|
||||
console.log(size1)
|
||||
console.log(size2)
|
||||
if (f.size > size1) {
|
||||
alert("File Size must be smaller than 10 MB");
|
||||
$("#id_file").value = 0;
|
||||
return false;
|
||||
}
|
||||
if (f.size > size2) {
|
||||
$('#id_offline').val('True');
|
||||
$('#id_offline').prop('checked','True');
|
||||
data.set($('#id_offline').attr('name'),$('#id_offline').prop('checked'));
|
||||
console.log("Set offline to True");
|
||||
$('#extra_message').text('Because of the large size, we recommend to use background processing. You will receive email when it is done.');
|
||||
$('#extra_message').addClass('message');
|
||||
}
|
||||
data.set("file",f);
|
||||
// data.append("file",f);
|
||||
|
||||
$("#id_file").replaceWith('<div id="id_file">'+files[0].name+' <a class="remove" href="javascript:void(0);"><b><font color="red">X</font></b></a></div>');
|
||||
},
|
||||
mouseenter:function(){$("#id_drop-files").css("background-color","#E9E9E4");},
|
||||
mouseleave:function(){$("#id_drop-files").css("background-color","#FFFFFF");},
|
||||
dragover:function(e){
|
||||
e.preventDefault();
|
||||
$("#id_drop-files").css("background-color","#E9E9E4");},
|
||||
dragleave:function(e){ e.preventDefault();},
|
||||
});
|
||||
$(document).on("click", "a.remove", function() {
|
||||
$(this).parent().replaceWith('<td><input id="id_file" name="file" type="file" /></td>');
|
||||
});
|
||||
});
|
||||
};
|
||||
</script>
|
||||
{% endblock %}
|
||||
$('#id_offline').prop('checked','True');
|
||||
data.set($('#id_offline').attr('name'),$('#id_offline').prop('checked'));
|
||||
console.log("Set offline to True");
|
||||
$('#extra_message').text('Because of the large size, we recommend to use background processing. You will receive email when it is done.');
|
||||
$('#extra_message').addClass('message');
|
||||
}
|
||||
data.set("file",f);
|
||||
// data.append("file",f);
|
||||
|
||||
$("#id_file").replaceWith('<div id="id_file">'+files[0].name+' <a class="remove" href="javascript:void(0);"><b><font color="red">X</font></b></a></div>');
|
||||
},
|
||||
mouseenter:function(){$("#id_drop-files").css("background-color","#E9E9E4");},
|
||||
mouseleave:function(){$("#id_drop-files").css("background-color","#FFFFFF");},
|
||||
dragover:function(e){
|
||||
e.preventDefault();
|
||||
$("#id_drop-files").css("background-color","#E9E9E4");},
|
||||
dragleave:function(e){ e.preventDefault();},
|
||||
});
|
||||
$(document).on("click", "a.remove", function() {
|
||||
$(this).parent().replaceWith('<td><input id="id_file" name="file" type="file" /></td>');
|
||||
});
|
||||
});
|
||||
};
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_workouts.html' %}
|
||||
{% endblock %}
|
||||
{% block sidebar %}
|
||||
{% include 'menu_workouts.html' %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -14,21 +14,82 @@
|
||||
</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');
|
||||
}
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
});
|
||||
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'
|
||||
|| $(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 %}
|
||||
|
||||
|
||||
@@ -76,22 +76,82 @@
|
||||
|
||||
<script 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() == 'water'
|
||||
|| $(this).val() == 'coastal'
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
$('#id_boattype').toggle(true);
|
||||
} else {
|
||||
$('#id_boattype').toggle(false);
|
||||
$('#id_boattype').val('1x');
|
||||
}
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
});
|
||||
$( 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',
|
||||
}
|
||||
|
||||
</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 %}
|
||||
|
||||
@@ -16,49 +16,105 @@
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var modality = $("#id_modality");
|
||||
var hidden = $("#id_waterboattype");
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var modality = $("#id_modality");
|
||||
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.
|
||||
// Use JS to do this in case the user doesn't have JS
|
||||
// enabled.
|
||||
// Hide the fields.
|
||||
// Use JS to do this in case the user doesn't have JS
|
||||
// enabled.
|
||||
|
||||
hidden.hide();
|
||||
hidden.hide();
|
||||
|
||||
if (modality.val() == 'water') {
|
||||
hidden.show();
|
||||
}
|
||||
if (modality.val() == 'water') {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// 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();
|
||||
var otwtypes = ['water','coastal','c-boat','churchboat']
|
||||
if (otwtypes.includes(Value)) {
|
||||
// Show the hidden fields.
|
||||
hidden.show();
|
||||
} 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("");
|
||||
}
|
||||
});
|
||||
// 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();
|
||||
var otwtypes = ['water','coastal','c-boat','churchboat']
|
||||
if (otwtypes.includes(Value)) {
|
||||
// Show the hidden fields.
|
||||
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 {
|
||||
// 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("");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
@@ -16,58 +16,93 @@
|
||||
</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)',
|
||||
}
|
||||
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var modality = $("#id_modality");
|
||||
var hidden = $("#id_waterboattype");
|
||||
|
||||
|
||||
// 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();
|
||||
} 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("");
|
||||
}
|
||||
$('#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 {
|
||||
$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() {
|
||||
if (this.checked) {
|
||||
$("#id_killparentswarning").html("<p><em>Warning: Deleted workouts cannot be recovered</em></p>");
|
||||
console.log('kill parents')
|
||||
$("#id_killparents").change(function() {
|
||||
if (this.checked) {
|
||||
$("#id_killparentswarning").html("<p><em>Warning: Deleted workouts cannot be recovered</em></p>");
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -100,6 +100,11 @@ def analysis_new(request,
|
||||
|
||||
waterboattype = mytypes.waterboattype
|
||||
|
||||
try:
|
||||
waterboattype = options['waterboattype']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if request.method == 'POST':
|
||||
thediv = get_call()
|
||||
dateform = DateRangeForm(request.POST)
|
||||
@@ -122,7 +127,7 @@ def analysis_new(request,
|
||||
modalities = [m[0] for m in mytypes.workouttypes]
|
||||
else: # pragma: no cover
|
||||
modalities = [modality]
|
||||
if modality != 'water':
|
||||
if modality not in ['water','rower']:
|
||||
waterboattype = [b[0] for b in mytypes.boattypes]
|
||||
|
||||
options['modalities'] = modalities
|
||||
@@ -133,7 +138,7 @@ def analysis_new(request,
|
||||
except KeyError:
|
||||
worldclass = False
|
||||
options['cpoverlay'] = worldclass
|
||||
|
||||
|
||||
chartform = AnalysisChoiceForm(request.POST)
|
||||
if chartform.is_valid():
|
||||
options['form'] = chartform.cleaned_data
|
||||
@@ -160,6 +165,9 @@ def analysis_new(request,
|
||||
for b in mytypes.boattypes:
|
||||
if b[0] not in waterboattype: # pragma: no cover
|
||||
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))
|
||||
@@ -179,11 +187,6 @@ def analysis_new(request,
|
||||
except (ValueError, AttributeError): # pragma: no cover
|
||||
pass
|
||||
|
||||
negtypes = []
|
||||
for b in mytypes.boattypes:
|
||||
if b[0] not in waterboattype: # pragma: no cover
|
||||
negtypes.append(b[0])
|
||||
|
||||
rankingtypes = [False,True]
|
||||
if ranking:
|
||||
rankingtypes = [True]
|
||||
|
||||
@@ -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