2024-02-25 20:02:20 +01:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% load has_group %}
|
|
|
|
|
2024-03-03 14:29:11 +01:00
|
|
|
{% block page_title %}Training Program{% endblock %}
|
2024-02-25 20:02:20 +01:00
|
|
|
|
|
|
|
{% 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-body">
|
|
|
|
{% if trainingprogram_list %}
|
2024-03-01 13:52:54 +01:00
|
|
|
<table class="table table-striped tablesorter" id="trainingprogram_table">
|
2024-02-25 20:02:20 +01:00
|
|
|
<thead>
|
2024-03-01 13:52:54 +01:00
|
|
|
<tr>
|
2024-03-02 18:13:02 +01:00
|
|
|
<th colspan="5" class="text-center">{{ date|date:"l j F Y" }}</th>
|
2024-03-01 13:52:54 +01:00
|
|
|
</tr>
|
2024-02-25 20:02:20 +01:00
|
|
|
</thead>
|
2024-03-01 13:52:54 +01:00
|
|
|
<tbody>
|
2024-02-25 20:02:20 +01:00
|
|
|
{% for trainingprogram in trainingprogram_list %}
|
2024-03-01 13:52:54 +01:00
|
|
|
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
2024-03-03 14:29:11 +01:00
|
|
|
<td><b>{{ trainingprogram.rank }}</b></td>
|
|
|
|
<td class="text-center"><a href="{% url 'passe_details' trainingprogram.passe.id %}">{{ trainingprogram.passe.label }}</a>{% if trainingprogram.repetition != 1 %} {{ trainingprogram.repetition }}{% endif %}</td>
|
2024-03-02 18:41:15 +01:00
|
|
|
<td class="text-center">{{ trainingprogram.number_of_skill}}</td>
|
|
|
|
<td class="text-center">{{ trainingprogram.difficulty }}</td>
|
2024-03-02 18:13:02 +01:00
|
|
|
{% if request.user|has_group:"trainer" %}
|
2024-03-03 14:29:11 +01:00
|
|
|
<td class="text-center p-2">
|
|
|
|
<a href="#" class="up" data-tp_id="{{ trainingprogram.id }}" data-rank="{{ trainingprogram.rank }}">
|
2024-03-02 18:13:02 +01:00
|
|
|
<button type="submit" value="" class="btn btn-icon btn-warning mr-2">
|
|
|
|
<i class="fas fa-chevron-up"></i>
|
|
|
|
</button>
|
|
|
|
</a>
|
2024-03-03 14:29:11 +01:00
|
|
|
|
|
|
|
<a href="#" class="down" data-tp_id="{{ trainingprogram.id }}" data-rank="{{ trainingprogram.rank }}">
|
2024-03-02 18:13:02 +01:00
|
|
|
<button type="submit" value="add" class="btn btn-icon btn-warning mr-2">
|
|
|
|
<i class="fas fa-chevron-down"></i>
|
|
|
|
</button>
|
|
|
|
</a>
|
|
|
|
</td>
|
|
|
|
{% endif %}
|
2024-03-01 13:52:54 +01:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
2024-02-25 20:02:20 +01:00
|
|
|
<tr>
|
2024-03-01 13:52:54 +01:00
|
|
|
<td colspan="2" class="text-right"><b>TOTAL</b></td>
|
|
|
|
<td class="text-center"><b>{{ number_of_skill }}</b></td>
|
|
|
|
<td class="text-center"><b>{{ difficulty }}</b></td>
|
2024-03-02 18:13:02 +01:00
|
|
|
{% if request.user|has_group:"trainer" %}
|
|
|
|
<td></td>
|
|
|
|
{% endif %}
|
2024-02-25 20:02:20 +01:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-02 18:13:02 +01:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block footerscript %}
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function(){
|
|
|
|
$(".up,.down").click(function(){
|
|
|
|
var row = $(this).parents("tr:first");
|
2024-03-03 14:29:11 +01:00
|
|
|
var first_td = row.find("td:first");
|
|
|
|
saved_rank = first_td.text(); // jusque là, ca marche !
|
|
|
|
// alert("Rank : " + saved_rank);
|
|
|
|
|
2024-03-02 18:13:02 +01:00
|
|
|
if ($(this).is(".up")) {
|
|
|
|
$.ajax({
|
|
|
|
url: "{% url 'switch_trainingprogram_line' %}",
|
|
|
|
method: "POST",
|
|
|
|
data: {
|
2024-03-03 14:29:11 +01:00
|
|
|
tpid: $(this).data('tp_id'),
|
|
|
|
direction: 0,
|
2024-03-02 18:13:02 +01:00
|
|
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
|
|
|
},
|
|
|
|
}).done(function() {
|
2024-03-03 14:29:11 +01:00
|
|
|
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>");
|
|
|
|
|
2024-03-02 18:13:02 +01:00
|
|
|
row.insertBefore(row.prev());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$.ajax({
|
|
|
|
url: "{% url 'switch_trainingprogram_line' %}",
|
|
|
|
method: "POST",
|
|
|
|
data: {
|
2024-03-03 14:29:11 +01:00
|
|
|
tpid: $(this).data('tp_id'),
|
|
|
|
direction: 1,
|
2024-03-02 18:13:02 +01:00
|
|
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
|
|
|
},
|
|
|
|
}).done(function() {
|
2024-03-03 14:29:11 +01:00
|
|
|
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>");
|
|
|
|
|
2024-03-02 18:13:02 +01:00
|
|
|
row.insertAfter(row.next());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2024-02-25 20:02:20 +01:00
|
|
|
{% endblock %}
|