131 lines
5.7 KiB
HTML
131 lines
5.7 KiB
HTML
{% extends "base.html" %}
|
|
{% load has_group %}
|
|
{% load is_user_equal_to_gymnast %}
|
|
|
|
{% block page_title %}Training Program{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="row justify-content-center">
|
|
<div class="col-12 col-sm-12 col-md-8 col-lg-8 col-xl-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h4 class="text-center">
|
|
{{ gymnast_training.gymnast }} - {{ gymnast_training.date|date:"l j F Y" }}
|
|
</h4>
|
|
</div>
|
|
<!-- <div class="col-1 ml-auto">test</div> -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-body pt-0 pb-0">
|
|
{% if training_rounds %}
|
|
<table class="table table-striped tablesorter" id="trainingprogram_table">
|
|
<tbody>
|
|
{% for round in training_rounds %}
|
|
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
|
<td><b>{{ round.rank }}</b></td>
|
|
<td class="text-center"><a href="{% url 'traininground_details' round.id %}">{{ round.training_round.label }}</a>{% if round.repetition != 1 %} {{ round.repetition }}{% endif %}</td>
|
|
<td class="text-center">{{ round.number_of_skill}}</td>
|
|
<td class="text-center">{{ round.difficulty }}</td>
|
|
{% if request.user|has_group:"trainer" %}
|
|
<td class="text-center p-2">
|
|
<a href="#" class="up" data-tp_id="{{ round.id }}" data-rank="{{ round.rank }}">
|
|
<button type="submit" value="" class="btn btn-icon btn-warning mr-2">
|
|
<i class="fas fa-chevron-up"></i>
|
|
</button>
|
|
</a>
|
|
|
|
<a href="#" class="down" data-tp_id="{{ round.id }}" data-rank="{{ round.rank }}">
|
|
<button type="submit" value="add" class="btn btn-icon btn-warning mr-2">
|
|
<i class="fas fa-chevron-down"></i>
|
|
</button>
|
|
</a>
|
|
</td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
<tr>
|
|
<td colspan="2" class="text-right"><b>TOTAL</b></td>
|
|
<td class="text-center"><b>{{ gymnast_training.number_of_skill }}</b></td>
|
|
<td class="text-center"><b>{{ gymnast_training.difficulty }}</b></td>
|
|
{% if request.user|has_group:"trainer" %}
|
|
<td></td>
|
|
{% endif %}
|
|
</tr>
|
|
</table>
|
|
{% else %}
|
|
No training round associated for this training.
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="card-footer pt-0 row">
|
|
<div class="col-md-6 text-muted pt-0">
|
|
</div>
|
|
<div class="col-md-6 text-right text-muted pt-0">
|
|
{% if request.user|has_group:"trainer" or request.user|is_user_equal_to_gymnast:gymnast_id %}
|
|
<a href="{% url 'gymnast_training_compose' gymnast_training.id %}">
|
|
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
|
<i class="fas fa-plus"></i>
|
|
</button>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block footerscript %}
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$(".up,.down").click(function(){
|
|
var row = $(this).parents("tr:first");
|
|
var first_td = row.find("td:first");
|
|
saved_rank = first_td.text(); // jusque là, ca marche !
|
|
// alert("Rank : " + saved_rank);
|
|
|
|
if ($(this).is(".up")) {
|
|
$.ajax({
|
|
url: "{% url 'switch_traininground' %}",
|
|
method: "POST",
|
|
data: {
|
|
tpid: $(this).data('tp_id'),
|
|
direction: 0,
|
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
|
},
|
|
}).done(function() {
|
|
var previous_td = row.prev().find('td:first');
|
|
saved_previous_rank = previous_td.text();
|
|
|
|
first_td.html("<b>" + String(saved_previous_rank) + "</b>");
|
|
previous_td.html("<b>" + String(saved_rank) + "</b>");
|
|
|
|
row.insertBefore(row.prev());
|
|
});
|
|
} else {
|
|
$.ajax({
|
|
url: "{% url 'switch_traininground' %}",
|
|
method: "POST",
|
|
data: {
|
|
tpid: $(this).data('tp_id'),
|
|
direction: 1,
|
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
|
},
|
|
}).done(function() {
|
|
var next = row.next().find('td:first');
|
|
saved_next_rank = previous_td.text();
|
|
|
|
first_td.html("<b>" + String(saved_next_rank) + "</b>");
|
|
next.html("<b>" + String(saved_rank) + "</b>");
|
|
|
|
row.insertAfter(row.next());
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %} |