Adding GymnastHasRoutine management.
This commit is contained in:
parent
8ee2fef0d7
commit
07e805970e
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 3.2.8 on 2021-12-05 14:12
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('objective', '0003_delete_gymnasthasroutine'),
|
||||
('people', '0001_initial'),
|
||||
('followup', '0004_alter_learnedskill_skill'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='gymnasthasroutine',
|
||||
name='gymnast',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='has_routine', to='people.gymnast', verbose_name='Gymnast'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='gymnasthasroutine',
|
||||
name='routine',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='done_by_gymnast', to='objective.routine', verbose_name='Routine'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='gymnasthasroutine',
|
||||
name='routine_type',
|
||||
field=models.PositiveSmallIntegerField(choices=[(0, 'Other'), (1, 'L1'), (2, 'L2'), (3, 'L3'), (4, 'L4'), (5, 'L1S'), (6, 'L2S'), (7, 'L3S'), (8, 'L4S')], default='1', verbose_name='Type'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 3.2.8 on 2021-12-05 12:01
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0001_initial'),
|
||||
('objective', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='GymnastHasRoutine',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('routine_type', models.PositiveSmallIntegerField(choices=[(0, 'Other'), (1, 'L1'), (2, 'L2'), (3, 'L3'), (4, 'L4'), (5, 'L1S'), (6, 'L2S'), (7, 'L3S'), (8, 'L4S')], default='1', verbose_name='Type')),
|
||||
('datebegin', models.DateField(default=datetime.date.today, verbose_name='Date begin')),
|
||||
('dateend', models.DateField(blank=True, default=datetime.date.today, null=True, verbose_name='Date end')),
|
||||
('gymnast', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='has_routine', to='people.gymnast', verbose_name='Gymnast')),
|
||||
('routine', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='used_by_gymnast', to='objective.routine', verbose_name='Routine')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Gymnast Has Routine',
|
||||
'verbose_name_plural': 'Gymnast Has Routines',
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
# Generated by Django 3.2.8 on 2021-12-05 14:12
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('objective', '0002_gymnasthasroutine'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name='GymnastHasRoutine',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,155 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% 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=" ">Link gymnast to routine</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{% url 'link_routine_to_gymnast' gymnastid %}" 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-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>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_routine" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Routine</label>
|
||||
<div class="col-sm-10 col-md-9 col-lg-9 col-xl-10 {% if form.routine.errors %}has-danger{% endif %}">
|
||||
{{ form.routine }}
|
||||
{{ form.routine_related }}
|
||||
{% if form.routine.errors %}
|
||||
<label class="text-danger" for="id_routine" id="routine_error">
|
||||
{% for error in form.routine.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_routine_type" class="col-4 col-sm-3 col-md-3 col-lg-3 col-xl-2 col-form-label">Routine Type</label>
|
||||
<div class="col-8 col-sm-4 col-md-3 col-lg-3 col-xl-2 {% if form.routine_type.errors %}has-danger{% endif %}">
|
||||
{{ form.routine_type }}
|
||||
{% if form.routine_type.errors %}
|
||||
<label class="text-danger" for="id_routine_type" id="routine_type_error">
|
||||
{% for error in form.routine_type.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="id_datebegin" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Date Begin</label>
|
||||
<div class="col-8 col-sm-10 col-md-10 col-lg-4 col-xl-3 {% if form.datebegin.errors %}has-danger{% endif %}">
|
||||
{{ form.datebegin }}
|
||||
{% if form.datebegin.errors %}
|
||||
<label class="text-danger" for="id_datebegin" id="datebegin-error">
|
||||
{% for error in form.datebegin.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="id_dateend" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Date End</label>
|
||||
<div class="col-8 col-sm-10 col-md-10 col-lg-4 col-xl-3 {% if form.dateend.errors %}has-danger{% endif %}">
|
||||
<div class="btn-toolbar-item input-with-icon">
|
||||
{{ form.dateend }}
|
||||
{% if form.dateend.errors %}
|
||||
<label class="text-danger" for="id_dateend" id="dateend-error">
|
||||
{% for error in form.dateend.errors %}{{ error }}{% endfor %}
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer pt-0 text-center">
|
||||
<input type="submit" value="Save" class="btn btn-warning" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block footerscript %}
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function(){
|
||||
blackDashboard.initDateTimePicker();
|
||||
|
||||
$('#gymnast').autocomplete({
|
||||
source: function(request, response){
|
||||
$.ajax({
|
||||
url: '/gymnast/lookup/?pattern=' + $('#gymnast').val(),
|
||||
type: 'GET',
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
if(data.length != 0){
|
||||
response($.map(data, function(item){
|
||||
return {
|
||||
label: item.Name,
|
||||
value: item.Name,
|
||||
gymnastid: 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.gymnastid);
|
||||
}
|
||||
});
|
||||
|
||||
$('#id_routine_related').autocomplete({
|
||||
source: function(request, response) {
|
||||
$.ajax({
|
||||
url: '/routine/lookup/?pattern=' + $('#id_routine_related').val(),
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.length != 0) {
|
||||
response($.map(data, function(item) {
|
||||
return {
|
||||
label: item.label,
|
||||
value: item.label,
|
||||
routineid: 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.routineid);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
<div class="row justify-content-center ml-3 pr-0">
|
||||
<div class="col-md-12 pr-0">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Routines</h4>
|
||||
</div>
|
||||
<div class="card-body pt-0 pb-0">
|
||||
{% if ghr_list.count %}
|
||||
<table class="table tablesorter table-striped table-condensed" data-sort="table" id="maintable">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th></th> -->
|
||||
<th style="width: 5%" class="header text-center">Type</th>
|
||||
<th style="width: 30%" class="header text-left">Label</th>
|
||||
<th style="width: 10%" class="header text-center">From</th>
|
||||
<th style="width: 10%" class="header text-center">To</th>
|
||||
<th style="width: 5%" class="header text-center">Diff.</th>
|
||||
<th style="width: 5%" class="header text-center">Level</th>
|
||||
<th style="width: 5%" class="header text-center">Rank</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ghr in ghr_list %}
|
||||
<tr>
|
||||
<!-- <td> -->
|
||||
<!-- <a href="{% url 'routine_update' ghr.routine.id %}"> -->
|
||||
<!-- <span class="tim-icons icon-pencil text-warning"></span> -->
|
||||
<!-- </a> -->
|
||||
<!-- </td> -->
|
||||
<td class="text-center">{{ ghr.get_routine_type_display }}</td>
|
||||
<td class="text-left"><a href="{% url 'routine_details' ghr.routine.id %}">{{ ghr.routine.longLabel }}</a></td>
|
||||
<td class="text-center">{{ ghr.datebegin | date:"d-m-Y"}}</td>
|
||||
<td class="text-center">{% if ghr.dateend %}{{ ghr.dateend | date:"d F Y" }}{% else %}… to now.{% endif %}</td>
|
||||
<td class="text-center">{{ ghr.routine.difficulty }}</td>
|
||||
<td class="text-center">{{ ghr.routine.level }}</td>
|
||||
<td class="text-center">{{ ghr.routine.rank }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
<p>There are no routines corresponding to your criterias</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-footer text-right text-muted pt-0">
|
||||
<a href="{% url 'link_routine_to_gymnast' gymnastid %}">
|
||||
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||||
<i class="tim-icons icon-simple-add"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue