Improve chronos details display
continuous-integration/drone/push Build is pending
Details
continuous-integration/drone/push Build is pending
Details
This commit is contained in:
parent
a58b12982a
commit
f057ca824c
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load get_value_at_index %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card mb-0">
|
||||
|
@ -7,27 +8,31 @@
|
|||
<h4 class="card-title"> Chrono from {{ date_begin | date:'d-m-Y' }} to {{ date_end | date:'d-m-Y' }}</h4>
|
||||
</div>
|
||||
<div class="card-body pb-0 mb-0">
|
||||
<div class="row mr-1 ml-1 pb-0 mb-0">
|
||||
<div class="col-md-4">
|
||||
<table class="table tablesorter table-striped" data-sort="table" id="chrono_values_table">
|
||||
<div class="row pb-0 mb-0">
|
||||
<div class="col-md-5">
|
||||
<table class="table table-condensed" id="chrono_values_table">
|
||||
{% for chrono in chrono_list %}
|
||||
<tr>
|
||||
{% for detail in chrono.details.all %}
|
||||
<td>{{ detail.value }}</td>
|
||||
{% with max_value=max_values|get_value_at_index:forloop.counter0 %}
|
||||
{% with min_value=min_values|get_value_at_index:forloop.counter0 %}
|
||||
<td class="{% if max_value.max_score == detail.value %}table-success{% endif %}{% if min_value.min_score == detail.value %}table-danger{% endif %}">{{ detail.value | floatformat:2 }}</td>
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
<td class="text-right"><b>{{ chrono.score }}</b></td>
|
||||
<td class="text-right"><b>{{ chrono.score | floatformat:2 }}</b></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
{% for element in average_values %}
|
||||
<td><b>{{ element.avg_score | floatformat:3 }}</b></td>
|
||||
<td><b>{{ element.avg_score | floatformat:2 }}</b></td>
|
||||
{% endfor %}
|
||||
<td class="text-right"><b></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-8 offset-md-1 alert {% if request.session.template == 0 %}skill-info{% else %}alert-secondary{% endif %} mr-0 pb-0 pl-1 pr-1">
|
||||
<canvas id="chartjs_chrono" class="chartjs" width="800" height="400"></canvas>
|
||||
<div class="col-md-7 alert {% if request.session.template == 0 %}skill-info{% else %}alert-secondary{% endif %}">
|
||||
<canvas id="chartjs_chrono" class="chartjs"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,6 +42,13 @@
|
|||
|
||||
{% block footerscript %}
|
||||
<script type="text/javascript">
|
||||
// $('#chrono_values_table').DataTable({
|
||||
// paging: false,
|
||||
// searching: false,
|
||||
// ordering: false,
|
||||
// "bInfo" : false,
|
||||
// });
|
||||
|
||||
var ctx = document.getElementById("chartjs_chrono").getContext("2d");
|
||||
var gradient_stroke_1 = ctx.createLinearGradient(0, 450, 0, 0);
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def get_value_at_index(list, index):
|
||||
return list[index]
|
|
@ -62,27 +62,29 @@ def average_jump_chrono_details(request, gymnast_id, routine_type=1, date_begin=
|
|||
gymnast = get_object_or_404(Gymnast, pk=gymnast_id)
|
||||
|
||||
base_queryset = ChronoDetails.objects \
|
||||
.filter(chrono__gymnast=gymnast_id, chrono__chrono_type=routine_type, chrono__date__gte=date_begin, chrono__date__lte=date_end)
|
||||
.filter(chrono__gymnast=gymnast_id, chrono__chrono_type=routine_type, chrono__date__gte=date_begin, chrono__date__lte=date_end) \
|
||||
.values('order') \
|
||||
|
||||
average_values = base_queryset \
|
||||
.values('order') \
|
||||
.annotate(avg_score=Avg('value')) \
|
||||
.order_by('order')
|
||||
# print(average_values)
|
||||
|
||||
max_values = base_queryset \
|
||||
.values('order') \
|
||||
.annotate(max_score=Max('value')) \
|
||||
.order_by('order')
|
||||
# print(max_values)
|
||||
|
||||
min_values = base_queryset \
|
||||
.values('order') \
|
||||
.annotate(min_score=Min('value')) \
|
||||
.order_by('order')
|
||||
# print(min_values)
|
||||
|
||||
# value_list = base_queryset.order_by('chrono', 'order')
|
||||
# stat_values = ChronoDetails.objects \
|
||||
# .filter(chrono__gymnast=gymnast_id, chrono__chrono_type=routine_type, chrono__date__gte=date_begin, chrono__date__lte=date_end) \
|
||||
# .values('order') \
|
||||
# .annotate(avg_score=Avg('value'), max_score=Max('value'), min_score=Min('value')) \
|
||||
# .order_by('order')
|
||||
# print(stat_values)
|
||||
|
||||
chrono_list = Chrono.objects.filter(gymnast=gymnast_id, date__gte=date_begin, date__lte=date_end, chrono_type=routine_type)
|
||||
# print(chrono_list)
|
||||
|
||||
context = {
|
||||
"gymnast": gymnast,
|
||||
|
@ -91,7 +93,7 @@ def average_jump_chrono_details(request, gymnast_id, routine_type=1, date_begin=
|
|||
"average_values": average_values,
|
||||
"max_values": max_values,
|
||||
"min_values": min_values,
|
||||
"chrono_list": chrono_list
|
||||
"chrono_list": chrono_list,
|
||||
}
|
||||
return render(request, "followup/chronos/list_details.html", context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue