129 lines
6.5 KiB
HTML
129 lines
6.5 KiB
HTML
|
{% 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-12 col-lg-8 col-xl-8">
|
||
|
<div class="card">
|
||
|
<div class="card-header">
|
||
|
<h4 class="">{% if plan_id %}Edit{% else %}Add{% endif %} an objective</h4>
|
||
|
</div>
|
||
|
<div class="card-body">
|
||
|
<form action="{% if plan_id %}{% url 'plan_update' plan_id %}{% else %}{% url 'plan_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">Date <span class="text-danger"><b>*</b></span></label>
|
||
|
<div class="col-sm-6 col-md-5 col-lg-4 col-xl-2 {% 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_gymnast" class="col-4 col-sm-3 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></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 ">
|
||
|
<label for="id_educative" class="col-4 col-sm-3 col-form-label">Skill <span class="text-danger"><b>*</b></span></label>
|
||
|
<div class="col-8 col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.educative.errors %}has-danger{% endif %}">
|
||
|
{{ form.educative }}
|
||
|
{{ form.educative_related }}
|
||
|
{% if form.educative.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.educative.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-group row ">
|
||
|
<label for="id_learning_step" class="col-4 col-sm-3 col-form-label">Learning step</label>
|
||
|
<div class="col-8 col-sm-4 col-md-3 {% if form.learning_step.errors %}has-danger{% endif %}">
|
||
|
{{ form.learning_step }}
|
||
|
{% if form.learning_step.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.learning_step.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">Points of attention</label>
|
||
|
<div class="col-8 col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.id_information.errors %}has-danger{% endif %}">
|
||
|
{{ form.informations }}
|
||
|
</div>
|
||
|
</div>
|
||
|
<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 gymnast_lookup = "{% url 'gymnast_lookup' %}";
|
||
|
const skill_lookup = "{% url 'skill_lookup' %}";
|
||
|
|
||
|
$(function(){
|
||
|
|
||
|
$('#id_date').datetimepicker({
|
||
|
format: 'YYYY-MM-DD'
|
||
|
});
|
||
|
blackDashboard.initDateTimePicker();
|
||
|
|
||
|
$('#id_educative_related').autocomplete({
|
||
|
source: function(request, response) {
|
||
|
$.ajax({
|
||
|
url: skill_lookup,
|
||
|
method: "POST",
|
||
|
data: {
|
||
|
pattern: $('#id_skill_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,
|
||
|
skillid: 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.skillid);
|
||
|
},
|
||
|
{% 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>
|
||
|
{% if request.session.template == 0 %}
|
||
|
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
|
||
|
{% else %}
|
||
|
<script src="{% static "js/template_users/gymnast_autocomplete.js" %}"></script>
|
||
|
{% endif %}
|
||
|
{% endblock %}
|