multi compare added
This commit is contained in:
@@ -13,6 +13,55 @@
|
|||||||
checkboxes[i].checked = source.checked;
|
checkboxes[i].checked = source.checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</script>
|
||||||
|
<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");
|
||||||
|
|
||||||
|
|
||||||
|
// 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("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@@ -23,21 +72,38 @@
|
|||||||
<h3>{{ team.name }} Team Workouts</h3>
|
<h3>{{ team.name }} Team Workouts</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
<div class="grid_4 alpha">
|
<div class="grid_6 alpha">
|
||||||
|
|
||||||
{% if team %}
|
{% if team %}
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
||||||
{% else %}
|
{% else %}
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/" method="post">
|
<form enctype="multipart/form-data" action="/rowers/team-compare-select/" method="post">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="grid_4 alpha">
|
||||||
<table>
|
<table>
|
||||||
{{ dateform.as_table }}
|
{{ dateform.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
|
<input name='daterange' class="button green" type="submit" value="Submit">
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2">
|
</form>
|
||||||
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
|
{% if team %}
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
||||||
|
{% else %}
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/team-compare-select/" method="post">
|
||||||
|
{% endif %}
|
||||||
|
<div class="grid_4 alpha">
|
||||||
|
<table>
|
||||||
|
{{ modalityform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
|
<input name='modalityform' class="button green" type="submit" value="Submit">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_5 prefix_1 omega">
|
<div class="grid_5 prefix_1 omega">
|
||||||
{% if team %}
|
{% if team %}
|
||||||
|
|||||||
@@ -3170,19 +3170,67 @@ def team_comparison_select(request,
|
|||||||
except Rower.DoesNotExist:
|
except Rower.DoesNotExist:
|
||||||
raise Http404("Rower doesn't exist")
|
raise Http404("Rower doesn't exist")
|
||||||
|
|
||||||
|
if 'startdate' in request.session:
|
||||||
|
startdate = iso8601.parse_date(request.session['startdate'])
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if 'enddate' in request.session:
|
||||||
|
enddate = iso8601.parse_date(request.session['enddate'])
|
||||||
|
|
||||||
|
|
||||||
|
if 'waterboattype' in request.session:
|
||||||
|
waterboattype = request.session['waterboattype']
|
||||||
|
else:
|
||||||
|
waterboattype = ['1x','2x','2-','4x','4-','8+']
|
||||||
|
|
||||||
|
|
||||||
|
if 'modalities' in request.session:
|
||||||
|
modalities = request.session['modalities']
|
||||||
|
if len(modalities) > 1:
|
||||||
|
modality = 'all'
|
||||||
|
else:
|
||||||
|
modality = modalities[0]
|
||||||
|
else:
|
||||||
|
modalities = [m[0] for m in types.workouttypes]
|
||||||
|
|
||||||
|
if request.method == 'POST' and 'daterange' in request.POST:
|
||||||
dateform = DateRangeForm(request.POST)
|
dateform = DateRangeForm(request.POST)
|
||||||
if dateform.is_valid():
|
if dateform.is_valid():
|
||||||
startdate = dateform.cleaned_data['startdate']
|
startdate = dateform.cleaned_data['startdate']
|
||||||
enddate = dateform.cleaned_data['enddate']
|
enddate = dateform.cleaned_data['enddate']
|
||||||
|
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||||
|
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||||
|
request.session['startdate'] = startdatestring
|
||||||
|
request.session['enddate'] = enddatestring
|
||||||
else:
|
else:
|
||||||
dateform = DateRangeForm(initial={
|
dateform = DateRangeForm(initial={
|
||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if request.method == 'POST' and 'modality' in request.POST:
|
||||||
|
modalityform = TrendFlexModalForm(request.POST)
|
||||||
|
if modalityform.is_valid():
|
||||||
|
modality = modalityform.cleaned_data['modality']
|
||||||
|
waterboattype = modalityform.cleaned_data['waterboattype']
|
||||||
|
if modality == 'all':
|
||||||
|
modalities = [m[0] for m in types.workouttypes]
|
||||||
|
else:
|
||||||
|
modalities = [modality]
|
||||||
|
|
||||||
|
if modality != 'water':
|
||||||
|
waterboattype = [b[0] for b in types.boattypes]
|
||||||
|
|
||||||
|
|
||||||
|
request.session['modalities'] = modalities
|
||||||
|
request.session['waterboattype'] = waterboattype
|
||||||
|
|
||||||
|
negtypes = []
|
||||||
|
for b in types.boattypes:
|
||||||
|
if b[0] not in waterboattype:
|
||||||
|
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))
|
||||||
enddate = enddate+datetime.timedelta(days=1)
|
enddate = enddate+datetime.timedelta(days=1)
|
||||||
@@ -3208,18 +3256,21 @@ def team_comparison_select(request,
|
|||||||
if theteam and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
|
if theteam and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
|
||||||
workouts = Workout.objects.filter(team=theteam,
|
workouts = Workout.objects.filter(team=theteam,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate).order_by("-date", "-starttime")
|
startdatetime__lte=enddate,
|
||||||
|
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
||||||
elif theteam and theteam.viewing == 'coachonly':
|
elif theteam and theteam.viewing == 'coachonly':
|
||||||
workouts = Workout.objects.filter(team=theteam,user=r,
|
workouts = Workout.objects.filter(team=theteam,user=r,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate).order_by("-date","-starttime")
|
startdatetime__lte=enddate,
|
||||||
|
workouttype__in=modalities).order_by("-date","-starttime").exclude(boattype__in=negtypes)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
theteam = None
|
theteam = None
|
||||||
workouts = Workout.objects.filter(user=r,
|
workouts = Workout.objects.filter(user=r,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate).order_by("-date", "-starttime")
|
startdatetime__lte=enddate,
|
||||||
|
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
||||||
|
|
||||||
query = request.GET.get('q')
|
query = request.GET.get('q')
|
||||||
if query:
|
if query:
|
||||||
@@ -3240,6 +3291,11 @@ def team_comparison_select(request,
|
|||||||
theid = 0
|
theid = 0
|
||||||
|
|
||||||
chartform = ChartParamChoiceForm(initial={'teamid':0})
|
chartform = ChartParamChoiceForm(initial={'teamid':0})
|
||||||
|
modalityform = TrendFlexModalForm(initial={
|
||||||
|
'modality':modality,
|
||||||
|
'waterboattype':waterboattype
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
@@ -3252,6 +3308,7 @@ def team_comparison_select(request,
|
|||||||
'team':theteam,
|
'team':theteam,
|
||||||
'form':form,
|
'form':form,
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
|
'modalityform':modalityform,
|
||||||
'teams':get_my_teams(request.user),
|
'teams':get_my_teams(request.user),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user