[WIP] Gymnast user
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c5d13e1685
commit
17f5270353
20
README.md
20
README.md
|
@ -24,6 +24,26 @@
|
|||
|
||||
## Applications
|
||||
|
||||
### Right
|
||||
|
||||
Il y a 3 types pe de droits :
|
||||
|
||||
- Administrateur
|
||||
- Entraineur (groupe `Trainer`)
|
||||
- Gymnaste (groupe `Gymnast`)
|
||||
|
||||
##### Administrateur
|
||||
|
||||
Il peut tout faire.
|
||||
|
||||
##### Entraîneur
|
||||
|
||||
Peut tout faire sauf :
|
||||
|
||||
- Gérer les skill
|
||||
- Gérer les Pays
|
||||
- Gérer les lieux
|
||||
|
||||
### Skill
|
||||
|
||||
### Learned Skill
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -19,11 +20,16 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Gymnast*</label>
|
||||
<div class="col-8 col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.gymnast.errors %}has-danger{% endif %}">
|
||||
{{ 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 %}
|
||||
<label for="id_date" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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 ">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -21,9 +22,14 @@
|
|||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
{{ 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 %}
|
||||
{% 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 ">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -20,10 +21,15 @@
|
|||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
{{ 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 %}
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -19,11 +20,16 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
{{ 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 %}
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -12,14 +13,19 @@
|
|||
<form action="{% if mindstate_id %}{% url 'mindstate_update' mindstate_id %}{% else %}{% url 'mindstate_create' %}{% endif %}" method="post" class="form-horizontal" id="formulaire" name="formulaire">
|
||||
{% csrf_token %}
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Gymnast*</label>
|
||||
<div class="col-8 col-sm-9 col-md-9 col-lg-9 col-xl-10 {% if form.date.errors %}has-danger{% endif %}">
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
{% if form.gymnast.errors %}
|
||||
<label class="text-danger" for="id_gymnast" id="gymnast-error">
|
||||
{% for error in form.gymnast.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
<label for="id_date" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
{% if form.gymnast.errors %}
|
||||
<label class="text-danger" for="id_gymnast" id="gymnast-error">
|
||||
{% for error in form.gymnast.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
{% 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>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -20,10 +21,15 @@
|
|||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
{{ 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 %}
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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 ">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static%}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -13,14 +14,15 @@
|
|||
{% csrf_token %}
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-5 col-sm-5 col-md-5 col-lg-5 col-xl-4 col-form-label">Gymnast *</label>
|
||||
<div class="col-sm-10 col-md-8 col-lg-8 col-xl-8 {% if form.date.errors %}has-danger{% endif %}">
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
{% if form.gymnast.errors %}
|
||||
<label class="text-danger" for="id_gymnast" id="gymnast-error">
|
||||
{% for error in form.gymnast.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
<label for="id_routine" class="col-5 col-sm-5 col-md-5 col-lg-5 col-xl-4 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
@ -13,14 +14,15 @@
|
|||
<form action="{% if score_id %}{% url 'score_update' score_id %}{% else %}{% url 'score_create' %}{% endif %}" method="post" class="form-horizontal" id="formulaire" name="formulaire">
|
||||
{% csrf_token %}
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Gymnast</label>
|
||||
<div class="col-8 col-sm-9 col-md-9 col-lg-9 col-xl-10 {% if form.date.errors %}has-danger{% endif %}">
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
{% if form.gymnast.errors %}
|
||||
<label class="text-danger" for="id_gymnast" id="gymnast-error">
|
||||
{% for error in form.gymnast.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
<label for="id_event" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<div class="col-7 col-sm-5 col-md-5 col-lg-5 col-xl-4 pr-0">
|
||||
{{ form.postal }}
|
||||
{% if form.postal.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.postal.errors %}{{error}}{% endfor %}</span>{% endif %}
|
||||
</div>s
|
||||
</div>
|
||||
<div class="col-12 col-sm-7 col-md-7 col-lg-7 col-xl-8">
|
||||
{{ form.city }}
|
||||
{% if form.city.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.city.errors %}{{error}}{% endfor %}</span>{% endif %}
|
||||
|
@ -60,7 +60,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" value="Sav-e" class="btn btn-warning" />
|
||||
<input type="submit" value="Save" class="btn btn-warning" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
<h4 class="card-title mb-0"><b>{{ place.name }}</b></h4>
|
||||
</div>
|
||||
<div class="card-body row">
|
||||
<div class="col-12" id="map" style='height: 500px;'></div>
|
||||
<div class="col-12" id="map" style="height: 500px;"></div>
|
||||
</div>
|
||||
<div class="card-body row">
|
||||
<div class="col-6">
|
||||
<address>
|
||||
<p>
|
||||
{{ place.address }}<br />
|
||||
{{ place.postal }} {{ place.city }}<br />
|
||||
{{ place.country.nameus }}
|
||||
</address>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
{% if place.nbkm %}{{ place.nbkm }}km<br />{% endif %}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "listing.html" %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block datacontent %}
|
||||
<div class="card mb-0">
|
||||
|
@ -9,11 +10,13 @@
|
|||
</div>
|
||||
<div class="col-1 ml-auto">
|
||||
<div class="text-right">
|
||||
<a href="{% url 'place_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<a href="{% url 'place_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -24,7 +27,9 @@
|
|||
<table class="table tablesorter table-striped" data-sort="table" id="place_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 3%"></th>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<th style="width: 3%"></th>
|
||||
{% endif %}
|
||||
<th class="header text-left" style="width: 27%">Name</th>
|
||||
<th class="header text-left" style="width: 35%">Address</th>
|
||||
<th class="header text-center" style="width: 10%">Zip</th>
|
||||
|
@ -37,11 +42,13 @@
|
|||
<tbody>
|
||||
{% for place in place_list %}
|
||||
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
||||
<td>
|
||||
<a href="{% url 'place_update' place.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<td>
|
||||
<a href="{% url 'place_update' place.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="text-left"><a href="{% url 'place_details' place.id %}">{{ place.name }}</a></td>
|
||||
<td class="text-left">{{ place.address }}</td>
|
||||
<td class="text-left">{{ place.postal}}</td>
|
||||
|
@ -65,11 +72,17 @@
|
|||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#place_table').tablesorter({
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
{% endif %}
|
||||
dateFormat: "uk",
|
||||
sortList: [[3,0], [1,0]]
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
sortList: [[3,0], [1,0]]
|
||||
{% else %}
|
||||
sortList: [[2,0], [0,0]]
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
$('#place_table').DataTable({
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block page_title %}{{ routine.short_label }}{% endblock %}
|
||||
|
||||
|
@ -44,7 +45,6 @@
|
|||
<h4>Informations</h4>
|
||||
<!-- <p>{{ skill.educative }}</p> -->
|
||||
<span id="comment">
|
||||
|
||||
{{ routine.to_markdown | safe }}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -53,21 +53,23 @@
|
|||
<div class="col-6">
|
||||
<a href="{% url 'routine_list' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-components"></i>
|
||||
<i class="tim-icons icon-double-left"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
<a href="{% url 'compose_routine' routine.id %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-molecule-40"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'routine_update' routine.id %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-pencil"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<a href="{% url 'compose_routine' routine.id %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-molecule-40"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'routine_update' routine.id %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-pencil"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "listing.html" %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block datacontent %}
|
||||
<div class="card mb-0">
|
||||
|
@ -9,11 +10,13 @@
|
|||
</div>
|
||||
<div class="col-1 ml-auto">
|
||||
<div class="text-right">
|
||||
<a href="{% url 'routine_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<a href="{% url 'routine_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -24,7 +27,9 @@
|
|||
<table class="table tablesorter table-striped" data-sort="table" id="routine_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 3%"></th>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<th style="width: 3%"></th>
|
||||
{% endif %}
|
||||
<th class="header text-left" style="width: 37%">Long Label</th>
|
||||
<th class="header text-left" style="width: 25%">Short Label</th>
|
||||
<th class="header text-center" style="width: 10%">Compétitive ?</th>
|
||||
|
@ -38,11 +43,13 @@
|
|||
<tbody>
|
||||
{% for routine in routine_list %}
|
||||
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
||||
<td>
|
||||
<a href="{% url 'routine_update' routine.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<td>
|
||||
<a href="{% url 'routine_update' routine.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="text-left"><a href="{% url 'routine_details' routine.id %}">{{ routine.long_label }}</a></td>
|
||||
<td class="text-left"><a href="{% url 'routine_details' routine.id %}">{{ routine.short_label }}</a></td>
|
||||
<td class="text-center">{% if routine.is_competitive %}<i class="fa fa-check text-success" aria-hidden="true"></i>{% else %}<i class="fa fa-times text-danger" aria-hidden="true"></i>{% endif %}</td>
|
||||
|
@ -67,10 +74,14 @@
|
|||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('routine_table').tablesorter({
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
sortList: [[1,0]]
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
headers: {
|
||||
0: { sorter: false },
|
||||
},
|
||||
sortList: [[1,0]]
|
||||
{% else %}
|
||||
sortList: [[0,0]]
|
||||
{% endif %}
|
||||
})
|
||||
|
||||
$('#routine_table').DataTable({
|
||||
|
|
|
@ -39,6 +39,13 @@
|
|||
{% if form.gender.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.gender.errors %}{{error}}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row {% if form.email.errors %}has-error has-feedback{% endif %}">
|
||||
<label for="id_email" class="col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label">Email</label>
|
||||
<div class="col-12 col-sm-10 col-md-9 col-lg-9 col-xl-9">
|
||||
{{ form.email }}
|
||||
{% if form.email.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.email.errors %}{{error}}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_club" class="col-4 col-sm-3 col-form-label">Club*</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 {% if form.club.errors %}has-danger{% endif %}">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
|
@ -13,14 +14,15 @@
|
|||
{% csrf_token %}
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Gymnast</label>
|
||||
<div class="col-sm-10 col-md-9 col-lg-9 col-xl-10 {% if form.gymnast.errors %}has-danger{% endif %}">
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
{% if form.gymnast.errors %}
|
||||
<label class="text-danger" for="id_gymnast" id="gymnast_error">
|
||||
{% for error in form.gymnast.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast *</label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% 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>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "listing.html" %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block datacontent %}
|
||||
<div class="card mb-0">
|
||||
|
@ -9,11 +10,13 @@
|
|||
</div>
|
||||
<div class="col-1 ml-auto">
|
||||
<div class="text-right">
|
||||
<a href="{% url 'gymnast_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<a href="{% url 'gymnast_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -24,7 +27,9 @@
|
|||
<table class="table tablesorter table-striped" data-sort="table" id="gymnast_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 3%"></th>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<th style="width: 3%"></th>
|
||||
{% endif %}
|
||||
<th class="header text-left" style="width: 20%">Lastname</th>
|
||||
<th class="header text-left" style="width: 20%">Firstname</th>
|
||||
<th class="header text-left" style="width: 10%">Gender</th>
|
||||
|
@ -35,11 +40,13 @@
|
|||
<tbody>
|
||||
{% for gymnast in gymnast_list %}
|
||||
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
||||
<td>
|
||||
<a href="{% url 'gymnast_update' gymnast.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<td>
|
||||
<a href="{% url 'gymnast_update' gymnast.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="text-left"><a href="{% url 'gymnast_details' gymnast.id %}">{{ gymnast.last_name }}</a></td>
|
||||
<td class="text-left"><a href="{% url 'gymnast_details' gymnast.id %}">{{ gymnast.first_name }}</a></td>
|
||||
<td class="text-left">{{ gymnast.get_gender_display }}</td>
|
||||
|
@ -61,11 +68,14 @@
|
|||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#gymnast_table').tablesorter({
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
dateFormat: "uk",
|
||||
sortList: [[1,0], [2,0]]
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
sortList: [[1,0], [2,0]]
|
||||
{% else %}
|
||||
sortList: [[0,0], [1,0]]
|
||||
{% endif %}
|
||||
})
|
||||
|
||||
$('#gymnast_table').DataTable({
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
@ -9,43 +10,54 @@
|
|||
<h5 class="card-category mb-0">{{ event.eventtype.name }}</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if event.datebegin.date == event.dateend.date %}
|
||||
<p>The <a href="#">{{ event.datebegin | date:"d-m-Y" }}</a> from <a href="#">{{ event.datebegin | date:"G:i" }}</a> to <a href="#">{{ event.dateend | date:"G:i" }}</a>
|
||||
{% else %}
|
||||
<p>From <a href="#">{{ event.datebegin | date:"d-m-Y, G:i" }}</a><br />
|
||||
To <a href="#">{{ event.dateend | date:"d-m-Y, G:i" }}</a>
|
||||
{% endif %}
|
||||
{% if event.number_of_week_from_today > 0 %}
|
||||
<br />In <span class="text-{% if event.number_of_week_from_today > 12 %}success{% elif event.number_of_week_from_today > 9 %}info{% elif event.number_of_week_from_today > 6 %}warning{% else %}danger{% endif %}"><b>{{event.number_of_week_from_today}} week(s)</b></span>
|
||||
{% endif %}
|
||||
</p>
|
||||
<address>
|
||||
{{ event.place.address }}<br \>
|
||||
{{ event.place.postal }} {{ event.place.city }}<br \>
|
||||
{{ event.place.country }}
|
||||
</address>
|
||||
{% if event.place.nbkm %}
|
||||
<p>{{ event.place.nbkm }}km ({{ event.place.timing }}min)</p>
|
||||
<br />
|
||||
{% endif %}
|
||||
<div class="row mb-4">
|
||||
<div class="col-6">
|
||||
{% if event.datebegin.date == event.dateend.date %}
|
||||
<p>The <a href="#">{{ event.datebegin | date:"d-m-Y" }}</a> from <a href="#">{{ event.datebegin | date:"G:i" }}</a> to <a href="#">{{ event.dateend | date:"G:i" }}</a>
|
||||
{% else %}
|
||||
<p>From <a href="#">{{ event.datebegin | date:"d-m-Y, G:i" }}</a><br />
|
||||
To <a href="#">{{ event.dateend | date:"d-m-Y, G:i" }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if event.number_of_week_from_today > 0 %}
|
||||
<br />In <span class="text-{% if event.number_of_week_from_today > 12 %}success{% elif event.number_of_week_from_today > 9 %}info{% elif event.number_of_week_from_today > 6 %}warning{% else %}danger{% endif %}"><b>{{event.number_of_week_from_today}} week(s)</b></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
<p>
|
||||
{{ event.place.address }}<br \>
|
||||
{{ event.place.postal }} {{ event.place.city }}<br \>
|
||||
{{ event.place.country }}
|
||||
</p>
|
||||
{% if event.place.nbkm %}
|
||||
<p>{{ event.place.nbkm }}km ({{ event.place.timing }}min)</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h5 class="title mb-1">Participants </h5>
|
||||
<input type="text" name="gymnast" placeholder="Add gymnast…" class="form-control mb-2" id="gymnast">
|
||||
<table class="table tablesorte table-condensed table-striped" id="gymmanst_participant">
|
||||
{% if gymnast_list %}
|
||||
{% for gymnast in gymnast_list %}
|
||||
<tr>
|
||||
<td class="text-left">
|
||||
<span class="tim-icons icon-simple-remove text-warning minusButton" data-gymnastid="{{ gymnast.0.id }}"></span>
|
||||
</td>
|
||||
<td class="text-left col-9">
|
||||
<a href="{% url 'gymnast_details' gymnast.0.id %}">{{ gymnast.0.last_name }}, {{ gymnast.0.first_name }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr class="minusButton"><td colspan="2">No partifcipants for now.</td></tr>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<input type="text" name="gymnast" placeholder="Add gymnast…" class="form-control mb-2" id="gymnast">
|
||||
{% endif %}
|
||||
{% if gymnast_list %}
|
||||
<table class="table tablesorte table-condensed table-striped" id="gymmanst_participant">
|
||||
{% for gymnast in gymnast_list %}
|
||||
<tr>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<td class="text-left">
|
||||
<span class="tim-icons icon-simple-remove text-warning minusButton" data-gymnastid="{{ gymnast.0.id }}"></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="text-left col-9">
|
||||
<a href="{% url 'gymnast_details' gymnast.0.id %}">{{ gymnast.0 }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No partifcipants for now.</p>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -57,12 +69,20 @@
|
|||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{{ event.to_markdown | safe }}
|
||||
<a href="{% url 'event_update' event.id %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-pencil"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% if event.informations %}
|
||||
{{ event.to_markdown | safe }}
|
||||
{% else %}
|
||||
No informations for this event.
|
||||
{% endif %}
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<p>
|
||||
<a href="{% url 'event_update' event.id %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-pencil"></i>
|
||||
</button>
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "listing.html" %}
|
||||
{% load has_group %}
|
||||
|
||||
{% block datacontent %}
|
||||
<div class="card mb-0">
|
||||
|
@ -10,11 +11,13 @@
|
|||
</div>
|
||||
<div class="col-1 ml-auto">
|
||||
<div class="text-right">
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<a href="{% url 'event_create' %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -25,7 +28,9 @@
|
|||
<table class="table tablesorter table-striped" data-sort="table" id="event_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 3%"></th>
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<th style="width: 3%"></th>
|
||||
{% endif %}
|
||||
<th class="text-left">Event</th>
|
||||
<th class="text-left">Type</th>
|
||||
<th class="text-center">Date</th>
|
||||
|
@ -36,11 +41,13 @@
|
|||
<tbody>
|
||||
{% for event in event_list %}
|
||||
<tr role="row" class="{% cycle 'odd' 'even' %}">
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
<td>
|
||||
<a href="{% url 'event_update' event.id %}">
|
||||
<span class="tim-icons icon-pencil text-warning"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="text-left"><a href="{% url 'event_details' event.id %}">{{ event.name }}</a></td>
|
||||
<td class="text-left">{{ event.eventtype.name }}</td>
|
||||
<td class="text-center">{{ event.datebegin | date:"d-m-Y"}}</td>
|
||||
|
@ -62,11 +69,15 @@
|
|||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#event_table').tablesorter({
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
dateFormat: "uk",
|
||||
sortList: [[3,1], [1,0]]
|
||||
{% if request.user|has_group:"Trainer" %}
|
||||
headers: {
|
||||
0: { sorter: false }, // disable first column
|
||||
},
|
||||
sortList: [[3,1], [1,0]]
|
||||
{% else %}
|
||||
sortList: [[2,1], [0,0]]
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
$('#event_table').DataTable({
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
def user_has_group_trainer(user):
|
||||
return user.groups.filter(name='Trainer').exists()
|
||||
|
||||
def user_has_group_gymnast(user):
|
||||
return user.groups.filter(name='Gymnast').exists()
|
|
@ -37,6 +37,7 @@ class ChronoForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -65,6 +66,7 @@ class LearnedSkillForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -141,6 +143,7 @@ class ScoreForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -194,6 +197,7 @@ class AccidentForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -246,6 +250,7 @@ class MindStateForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -288,6 +293,7 @@ class GymnastHasRoutineForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -352,6 +358,7 @@ class HeightWeightForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -401,6 +408,7 @@ class NumberOfRoutineDoneForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -446,6 +454,7 @@ class PlanForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
|
|
@ -7,6 +7,9 @@ from django.http import HttpResponse, HttpResponseRedirect
|
|||
from django.db.models import Q, Min, Avg, Max, Sum
|
||||
from django.urls import reverse
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
User = get_user_model()
|
||||
|
||||
from ultron.people.models import Gymnast
|
||||
from ultron.planning.models import Event
|
||||
from ultron.objective.models import Skill
|
||||
|
@ -179,8 +182,9 @@ def chrono_create_or_update(request, chrono_id=None, gymnast_id=None):
|
|||
|
||||
new_chrono.save()
|
||||
return HttpResponseRedirect(reverse("gymnast_details", args=(new_chrono.gymnast.id,)))
|
||||
|
||||
else:
|
||||
else:
|
||||
print(form.errors)
|
||||
else:
|
||||
form = ChronoForm(instance=chrono, initial=data)
|
||||
|
||||
context = {"form": form, "chrono_id": chrono_id}
|
||||
|
|
|
@ -5,9 +5,20 @@ from .models import Gymnast
|
|||
class GymnastAdmin(admin.ModelAdmin):
|
||||
model = Gymnast
|
||||
|
||||
def last_name(self, obj):
|
||||
return obj.user.last_name
|
||||
|
||||
def first_name(self, obj):
|
||||
return obj.user.first_name
|
||||
|
||||
def email(self, obj):
|
||||
return obj.user.email
|
||||
|
||||
def is_active(self, obj):
|
||||
return obj.user.is_active
|
||||
|
||||
fields = (
|
||||
"last_name",
|
||||
"first_name",
|
||||
"user",
|
||||
"birthdate",
|
||||
"gender",
|
||||
"trainings_by_week",
|
||||
|
@ -17,7 +28,7 @@ class GymnastAdmin(admin.ModelAdmin):
|
|||
)
|
||||
|
||||
list_display = ("last_name", "first_name", "age", "is_active") # , 'club'
|
||||
list_filter = ("gender", "is_active") # , 'club'
|
||||
list_filter = ("gender", "user__is_active") # , 'club'
|
||||
search_fields = ("last_name", "first_name")
|
||||
# autocomplete_fields = ('club',)
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"""Formulaires de gestion des données entrantes pour les gymnastes et accidents."""
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from .models import Gymnast
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class GymnastForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
@ -40,6 +43,23 @@ class GymnastForm(forms.ModelForm):
|
|||
)
|
||||
}
|
||||
|
||||
last_name = forms.CharField(
|
||||
widget=forms.TextInput(
|
||||
attrs={"class": "form-control", "placeholder": "Lastname"}
|
||||
)
|
||||
)
|
||||
first_name = forms.CharField(
|
||||
widget=forms.TextInput(
|
||||
attrs={"class": "form-control", "placeholder": "Firstname"}
|
||||
)
|
||||
)
|
||||
email = forms.EmailField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={"class": "form-control", "placeholder": "my_email@email.com"}
|
||||
)
|
||||
)
|
||||
|
||||
club_related = forms.CharField(
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
|
@ -49,3 +69,15 @@ class GymnastForm(forms.ModelForm):
|
|||
}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = (
|
||||
"last_name",
|
||||
"first_name",
|
||||
"email",
|
||||
"is_active",
|
||||
"username",
|
||||
)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 3.2.8 on 2022-02-04 10:29
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('people', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='gymnast',
|
||||
name='user',
|
||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='gymnast', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models import Count
|
||||
from django.db import models
|
||||
User = get_user_model()
|
||||
|
||||
from datetime import date
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Count
|
||||
|
||||
import pendulum
|
||||
|
||||
from ultron.location.models import Club
|
||||
|
@ -22,6 +23,13 @@ class Gymnast(Markdownizable):
|
|||
|
||||
GENDER_CHOICES = ((0, "Male"), (1, "Female"))
|
||||
|
||||
user = models.OneToOneField(
|
||||
User,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="gymnast",
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
last_name = models.CharField(max_length=40, null=False, blank=False)
|
||||
first_name = models.CharField(max_length=25, null=False, blank=False)
|
||||
birthdate = models.DateField(verbose_name="Date de naissance")
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import Group
|
||||
from django.contrib.auth import get_user_model
|
||||
User = get_user_model()
|
||||
|
||||
from django.db.models import Q, F, Avg
|
||||
from django.db.models.functions import TruncDay
|
||||
from django.http import HttpResponseRedirect, JsonResponse
|
||||
|
@ -7,6 +11,7 @@ from django.shortcuts import render, get_object_or_404
|
|||
from django.views.decorators.http import require_http_methods
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
import pendulum
|
||||
|
||||
from ultron.followup.models import Event
|
||||
|
@ -23,7 +28,7 @@ from ultron.followup.models import (
|
|||
)
|
||||
|
||||
from .models import Gymnast
|
||||
from .forms import GymnastForm
|
||||
from .forms import GymnastForm, UserForm
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -277,6 +282,21 @@ def gymnast_create_or_update(request, gymnast_id=None):
|
|||
|
||||
if gymnast_form.is_valid():
|
||||
gymnast = gymnast_form.save()
|
||||
form_data = request.POST.dict()
|
||||
form_data['username'] = gymnast.first_name.lower() + '_' + gymnast.last_name.lower()
|
||||
user_form = UserForm(form_data, instance=gymnast.user)
|
||||
|
||||
if user_form.is_valid():
|
||||
user = user_form.save()
|
||||
|
||||
gymnast_group = Group.objects.get(name='Gymnast')
|
||||
user.groups.add(gymnast_group)
|
||||
|
||||
gymnast.user = user
|
||||
gymnast.save()
|
||||
# if not user.has_usable_password():
|
||||
# user.set_password(gymnast.last_name.lower() + _ + str(gymnast.birthdate)[-2:])
|
||||
|
||||
return HttpResponseRedirect(reverse("gymnast_details", args=(gymnast.pk,)))
|
||||
|
||||
form = GymnastForm(instance=gymnast, initial=data)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from django import template
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def has_group(user, group_name):
|
||||
return user.groups.filter(name=group_name).exists()
|
Loading…
Reference in New Issue