Move template
This commit is contained in:
parent
04dcbc7ddb
commit
f38e0934db
|
@ -0,0 +1,105 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% 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">
|
||||
<h4 class="">{% if injury_id %}Edit{% else %}Add{% endif %} injury</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{% if injury_id %}{% url 'injury_update' injury_id %}{% else %}{% url 'injury_create' %}{% endif %}" method="post" class="form-horizontal" id="formulaire" name="formulaire">
|
||||
{% csrf_token %}
|
||||
<div class="form-group row ">
|
||||
<label for="id_date" class="col-4 col-sm-3 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
{% if request.user|has_group:"trainer" %}
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
{% if form.gymnast.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.gymnast.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
{% else %}
|
||||
<input type="text" class="form-control" value="{{ request.user.first_name }} {{ request.user.last_name }}" readonly="readonly" />
|
||||
<input type="hidden" name="gymnast" id="gymnast" value="{{ request.user.gymnast.id }}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_date" class="col-4 col-sm-3 col-form-label">{{ form.date.label }} <span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-sm-3 col-md-4 col-lg-4 col-xl-4 {% if form.date.errors %}has-danger{% endif %}">
|
||||
{{ form.date }}
|
||||
{% if form.date.errors %}<span class="btn btn-sm btn-danger-outline">{% for error in form.date.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_skill" class="col-4 col-sm-3 col-form-label">Skill</label>
|
||||
<div class="col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.skill.errors %}has-danger{% endif %}">
|
||||
{{ form.skill }}
|
||||
{{ form.skill_related }}
|
||||
{% if form.skill.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.skill.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_mechanism" class="col-4 col-sm-3 col-form-label">{{ form.mechanism.label }} <span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-5 col-sm-3 col-md-4 col-lg-4 col-xl-4 {% if form.mechanism.errors %}has-danger{% endif %}">
|
||||
{{ form.mechanism }}
|
||||
{% if form.mechanism.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.mechanism.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_location" class="col-4 col-sm-3 col-form-label">{{ form.location.label }}<span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.location.errors %}has-danger{% endif %}">
|
||||
{{ form.location }}
|
||||
{% if form.location.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.location.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_body_side" class="col-4 col-sm-3 col-form-label">{{ form.body_side.label }}<span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-5 col-sm-3 col-md-4 col-lg-4 col-xl-4 {% if form.body_side.errors %}has-danger{% endif %}">
|
||||
{{ form.body_side }}
|
||||
{% if form.body_side.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.body_side.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_nb_week_off" class="col-4 col-sm-3 col-form-label"># Week off</label>
|
||||
<div class="col-sm-3 col-md-4 col-lg-2 {% if form.nb_week_off.errors %}has-danger{% endif %}">
|
||||
{{ form.nb_week_off }}
|
||||
{% if form.nb_week_off.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.nb_week_off.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_information" class="col-4 col-sm-3 col-form-label">Informations</label>
|
||||
<div class="col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.id_informations.errors %}has-danger{% endif %}">
|
||||
{{ form.informations }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" value="{% if injury_id %}Save{% else %}Add{% endif %}" class="btn btn-warning" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block footerscript %}
|
||||
<script type="text/javascript" >
|
||||
$(function(){
|
||||
blackDashboard.initDateTimePicker();
|
||||
});
|
||||
|
||||
const csrf_token = "{{ csrf_token|escapejs }}";
|
||||
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
|
||||
const skill_lookup = "{% url 'skill_lookup' %}";
|
||||
</script>
|
||||
<script src="{% static "js/template_users/datepicker_maxdate_today.js" %}"></script>
|
||||
{% if request.session.template == 0 %}
|
||||
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
|
||||
<script src="{% static "js/template_users/skill_autocomplete_black.js" %}"></script>
|
||||
{% else %}
|
||||
<script src="{% static "js/template_users/gymnast_autocomplete.js" %}"></script>
|
||||
<script src="{% static "js/template_users/skill_autocomplete.js" %}"></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,33 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-sm-8 col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="mb-0">Injury on {{ injury.date | date:"j N Y" }}</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<a href="{% url 'gymnast_details' injury.gymnast.id %}">{{ injury.gymnast }}</a>{% if injury.skill %} injuried on <i>{{ injury.skill.notation }}</i>{% endif %}<br />
|
||||
{{ injury.get_mechanism_display }} on {{ injury.location}} ({{ injury.get_body_side_display }})<br />
|
||||
{% if injury.nb_week_off %}
|
||||
Gymnast {{ injury.nb_week_off }} week(s) off.<br />
|
||||
{% endif %}
|
||||
<br />
|
||||
|
||||
{{ injury.to_markdown | safe }}
|
||||
|
||||
<div class="card-footer pl-0 pb-0">
|
||||
<a href="{% url 'injuries_list' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-double-left"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,96 @@
|
|||
{% extends "listing.html" %}
|
||||
|
||||
{% block datacontent %}
|
||||
<div class="card mb-0">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h4 class=""> Injuries Listing</h4>
|
||||
</div>
|
||||
<div class="col-1 ml-auto">
|
||||
<div class="text-right">
|
||||
<a href="{% url 'injury_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
{% if injuries_list %}
|
||||
<table class="table tablesorter table-striped" data-sort="table" id="injury_table">
|
||||
<thead class="text-primary">
|
||||
<tr>
|
||||
<th style="width: 3%"></th>
|
||||
<th class="header text-left" style="width: 8%">Date</th>
|
||||
<th class="header text-left" style="width: 20%">Gymnast</th>
|
||||
<th class="header text-left" style="width: 9%">Mechanism</th>
|
||||
<th class="header text-left" style="width: 20%">Location</th>
|
||||
<th class="header text-left" style="width: 8%">Side</th>
|
||||
<th style="width: 12%">Skill</th>
|
||||
<th style="width: 8%"># Week off</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for injury in injuries_list %}
|
||||
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
||||
<td>
|
||||
<a href="{% url 'injury_update' injury.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-left"><a href="{% url 'injury_details' injury.id %}">{{ injury.date | date:"d-m-Y" }}</a></td>
|
||||
<td class="text-left"><a href="{% url 'gymnast_details_tab' injury.gymnast.id 'physiological' %}">{{ injury.gymnast }}</a></td>
|
||||
<td class="text-left">{{ injury.get_mechanism_display }}</td>
|
||||
<td class="text-left">{{ injury.location }}</td>
|
||||
<td class="text-left">{{ injury.get_body_side_display }}</td>
|
||||
<td class="text-left">
|
||||
{% if injury.skill %}
|
||||
<a href="{% url 'skill_details' injury.skill.id %}">{{ injury.skill.notation }}</a>
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
{% if injury.nb_week_off %}
|
||||
{{ injury.nb_week_off }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="muted-text">There are no injury corresponding to your criterias.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block footerscript %}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('#injury_table').tablesorter({
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
dateFormat: "uk",
|
||||
sortList: [[1, 1]]
|
||||
});
|
||||
|
||||
$('#injury_table').DataTable({
|
||||
scrollY: 500,
|
||||
paging: false,
|
||||
searching: false,
|
||||
ordering: false,
|
||||
"bInfo": false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -341,10 +341,9 @@ def score_listing(request, gymnast_id=None):
|
|||
@require_http_methods(["GET"])
|
||||
def injury_listing(request):
|
||||
"""
|
||||
Récupère la liste des accidents.
|
||||
Récupère la liste des blessures.
|
||||
Si c'est un gymnaste qui est connecté, il ne peut récupérer que la liste de ses accidents.
|
||||
Si c'est un autre utilisateur (entraîneur), la liste peut répondre à un pattern si celui-ci est
|
||||
définit.
|
||||
Si c'est un entraîneur, la liste peut répondre à un pattern si celui-ci est définit.
|
||||
"""
|
||||
|
||||
if request.user.groups.filter(name="trainer").exists():
|
||||
|
|
Loading…
Reference in New Issue