2023-04-25 17:06:14 +02:00
{% extends "base.html" %}
{% block content %}
< div class = "row justify-content-center" >
< div class = "col-12 col-sm-12 col-md-12 col-lg-8 col-xl-8" >
< div class = "card" >
< div class = "card-header" >
< h4 class = "" > {% if gymnast_id %}Edit{% else %}Add{% endif %} Gymnast< / h4 >
< / div >
< div class = "card-body" >
< form action = "{% if gymnast_id %}{% url 'gymnast_update' gymnast_id %}{% else %}{% url 'gymnast_create' %}{% endif %}" method = "post" class = "form-horizontal" id = "form" name = "form" >
{% csrf_token %}
< div class = "form-group row {% if form.last_name.errors %}has-error has-feedback{% endif %}" >
< label for = "id_last_name" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Names < span class = "text-danger" > < b > *< / b > < / span > < / label >
< div class = "col-8 col-sm-9 col-md-9 col-lg-9 col-xl-9" >
< div class = "row" >
< div class = "col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 pr-0" >
{{ form.first_name }}
2024-04-24 10:04:37 +02:00
{% if form.first_name.errors %} < span class = "btn btn-sm" > {% for error in form.first_name.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< div class = "col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6" >
{{ form.last_name }}
2024-04-24 10:04:37 +02:00
{% if form.last_name.errors %} < span class = "btn btn-sm" > {% for error in form.last_name.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< / div >
< / div >
< / div >
< div class = "form-group row {% if form.birthdate.errors %}has-error has-feedback{% endif %}" >
< label for = "id_birthdate" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Birthdate < span class = "text-danger" > < b > *< / b > < / span > < / label >
< div class = "col-8 col-sm-3 col-md-3 col-lg-3 col-xl-3" >
{{ form.birthdate }}
2024-04-24 10:04:37 +02:00
{% if form.birthdate.errors %} < span class = "btn btn-sm" > {% for error in form.birthdate.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< / div >
< div class = "form-group row {% if form.gender.errors %}has-error has-feedback{% endif %}" >
< label for = "id_gender" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Gender < span class = "text-danger" > < b > *< / b > < / span > < / label >
< div class = "col-8 col-sm-3 col-md-3 col-lg-3 col-xl-3" >
{{ form.gender }}
2024-04-24 10:04:37 +02:00
{% if form.gender.errors %} < span class = "btn btn-sm" > {% for error in form.gender.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / 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-6 col-lg-6 col-xl-6" >
{{ form.email }}
2024-04-24 10:04:37 +02:00
{% if form.email.errors %} < span class = "btn btn-sm" > {% for error in form.email.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< / div >
< div class = "form-group row {% if form.orientation.errors %}has-error has-feedback{% endif %}" >
< label for = "id_orientation" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Orientation < span class = "text-danger" > < b > *< / b > < / span > < / label >
< div class = "col-8 col-sm-3 col-md-3 col-lg-2 col-xl-2" >
{{ form.orientation }}
2024-04-24 10:04:37 +02:00
{% if form.orientation.errors %} < span class = "btn btn-sm" > {% for error in form.orientation.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< / div >
< div class = "form-group row" >
< label for = "id_year_of_practice" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Year of practice < span class = "text-danger" > < b > *< / b > < / span > < / label >
< div class = "col-8 col-sm-3 col-md-3 col-lg-2 col-xl-2" >
< div class = "form-group {% if form.year_of_practice.errors %}has-error{% endif %}" >
{{ form.year_of_practice }}
{% if form.year_of_practice.errors %}
< label id = "id_year_of_practice-error" class = "text-danger" for = "id_year_of_practice" >
{% for error in form.year_of_practice.errors %}{{ error }}{% endfor %}
< / label >
{% endif %}
< / div >
< / div >
< / div >
< div class = "form-group row {% if form.email.errors %}has-error has-feedback{% endif %}" >
< label for = "id_email_trainer" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Email trainer< / label >
< div class = "col-12 col-sm-10 col-md-6 col-lg-6 col-xl-6" >
{{ form.email_trainer }}
2024-04-24 10:04:37 +02:00
{% if form.email_trainer.errors %} < span class = "btn btn-sm" > {% for error in form.email_trainer.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< / div >
< div class = "form-group row " >
< label for = "id_information" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Informations< / label >
< div class = "col-8 col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.id_informations.errors %}has-danger{% endif %}" >
{{ form.informations }}
< / div >
< / div >
{% if gymnast_id %}
< div class = "form-group row {% if form.is_active.errors %}has-error has-feedback{% endif %}" >
< label for = "id_is_active" class = "col-4 col-sm-2 col-md-3 col-lg-3 col-xl-3 col-form-label" > Is active< / label >
< div class = "col-8 col-sm-2 col-md-2 col-lg-2 col-xl-2" >
{{ form.is_active }}
2024-04-24 10:04:37 +02:00
{% if form.is_active.errors %} < span class = "btn btn-sm" > {% for error in form.is_active.errors %}{{ error }}{% endfor %}< / span > {% endif %}
2023-04-25 17:06:14 +02:00
< / div >
< / div >
{% else %}
< input type = "hidden" value = "1" name = "{{ form.is_active.name }}" id = "id_is_active" >
{% endif %}
< div class = "form-group text-center" >
< input type = "submit" value = "Save" class = "btn btn-fill btn-warning" / >
< / div >
< / form >
< / div >
< / div >
< / div >
< / div >
{% endblock %}
{% block footerscript %}
< script type = "text/javascript" >
const csrf_token = "{{ csrf_token|escapejs }}";
const club_lookup = "{% url 'club_lookup' %}";
$(function(){
$('#id_birthdate').datetimepicker({
format: 'YYYY-MM-DD'
});
blackDashboard.initDateTimePicker();
$('#id_hours_by_week').focusout(function(){
value = $(this).val().replace(/,/g, '.');
$(this).val(parseFloat(value).toFixed(1));
});
$('#form').submit(function(){
$('#id_hours_by_week').val().replace(/,/g, '.');
$('#id_hours_by_week').val(parseFloat(value).toFixed(1));
})
$('#id_club_related').autocomplete({
source: function(request, response) {
$.ajax({
url: club_lookup,
method: "POST",
data: {
pattern: $('#id_club_related').val(),
csrfmiddlewaretoken: csrf_token
},
dataType: "json",
success: function(data) {
if(data.length != 0) {
response($.map(data, function(item) {
return {
label: item.Name,
value: item.Name,
clubid: item.ID
}
}))
} else {
response([{ label: 'No result found.', value: '' }]);
};
},
error: function (exception) {
console.log(exception);
}
});
},
minLength: 3,
select: function (event, ui) {
$($(this).data('ref')).val(ui.item.clubid);
},
{% if request.session.template == 0 %}
classes: {
"ui-widget-content": "custom_autocomplete_ul",
"ui-autocomplete": "custom_autocomplete_ul",
"ui-menu-item-wrapper": "custom_autocomplete_li",
"ui-menu-item": "custom_autocomplete_li",
},
{% endif %}
});
});
< / script >
{% endblock %}