mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-21 07:22:14 +00:00
Rework level list display
This commit is contained in:
@@ -184,6 +184,16 @@ class TrainingLevel(models.Model, RevisionMixin):
|
|||||||
def passed_out_requirements(self):
|
def passed_out_requirements(self):
|
||||||
return self.get_requirements_of_depth(TrainingItemQualification.PASSED_OUT)
|
return self.get_requirements_of_depth(TrainingItemQualification.PASSED_OUT)
|
||||||
|
|
||||||
|
def get_related_level(self, dif):
|
||||||
|
if (level == 0 and dif < 0) or (level == 2 and dif > 0):
|
||||||
|
return None
|
||||||
|
return TrainingLevel.objects.get(department=self.department, level=self.level+dif)
|
||||||
|
|
||||||
|
def get_common_competencies(self):
|
||||||
|
if is_common_competencies:
|
||||||
|
return self
|
||||||
|
return TrainingLevel.objects.get(level=self.level, department=None)
|
||||||
|
|
||||||
def percentage_complete(self, user): # FIXME
|
def percentage_complete(self, user): # FIXME
|
||||||
needed_qualifications = self.requirements.all().select_related()
|
needed_qualifications = self.requirements.all().select_related()
|
||||||
relavant_qualifications = 0.0
|
relavant_qualifications = 0.0
|
||||||
|
|||||||
@@ -1,19 +1,76 @@
|
|||||||
{% extends 'base_training.html' %}
|
{% extends 'base_training.html' %}
|
||||||
|
|
||||||
{% load markdown_tags %}
|
{% load markdown_tags %}
|
||||||
|
{% load get_supervisor from tags %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<style>
|
<style>
|
||||||
.level-1::after {
|
.tree ul {
|
||||||
content: "";
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li {
|
||||||
|
list-style-type: none;
|
||||||
|
margin:10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 50%;
|
}
|
||||||
transform: translateX(-50%);
|
|
||||||
width: 2px;
|
.tree li::before {
|
||||||
height: 50px;
|
content: "";
|
||||||
margin-top: -15px;
|
position: absolute;
|
||||||
margin-bottom: -15px;
|
top:-7px;
|
||||||
background: black;
|
left:-20px;
|
||||||
|
border-left: 1px solid #ccc;
|
||||||
|
border-bottom:1px solid #ccc;
|
||||||
|
border-radius:0 0 0 0px;
|
||||||
|
width:20px;
|
||||||
|
height:15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li::after {
|
||||||
|
position:absolute;
|
||||||
|
content:"";
|
||||||
|
top:8px;
|
||||||
|
left:-20px;
|
||||||
|
border-left: 1px solid #ccc;
|
||||||
|
border-top:1px solid #ccc;
|
||||||
|
border-radius:0px 0 0 0;
|
||||||
|
width:20px;
|
||||||
|
height:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li:last-child::after {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li:last-child:before{
|
||||||
|
border-radius: 0 0 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.tree>li:first-child::before {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.tree>li:first-child::after {
|
||||||
|
border-radius:5px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li a {
|
||||||
|
border: 1px #ccc solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding:2px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li a:hover, .tree li a:hover+ul li a,
|
||||||
|
.tree li a:focus, .tree li a:focus+ul li a {
|
||||||
|
background: #ccc; color: #000; border: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree li a:hover+ul li::after, .tree li a:focus+ul li::after,
|
||||||
|
.tree li a:hover+ul li::before, .tree li a:focus+ul li::before
|
||||||
|
.tree li a:hover+ul::before, .tree li a:focus+ul::before
|
||||||
|
.tree li a:hover+ul ul::before, .tree li a:focus+ul ul::before{
|
||||||
|
border-color: #000; /*connector color on hover*/
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -28,28 +85,17 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<sup>Correct as of 3rd September 2021, check the Training Policy.</sup>
|
<sup>Correct as of 3rd September 2021, check the Training Policy.</sup>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart">
|
<ul class="tree">
|
||||||
{% for level in levels %}
|
<li><div class="card"><div class="card-header">{{ta}}</div><div class="card-body">{{ta.description|markdown}}</div></div>
|
||||||
{% if forloop.counter == 3 %}
|
<ul>
|
||||||
<div class="row">
|
{% for level in tech %}
|
||||||
<div class="col-6">
|
<li><div class="card"><div class="card-header">{{level}}</div><div class="card-body">{{level.description|markdown}}</div></div>
|
||||||
{% endif %}
|
<ul>
|
||||||
{% if level.level == 2 and level.department is None %}
|
<li><div class="card p-3">{{level|get_supervisor}}</div></li>
|
||||||
</div>
|
</ul>
|
||||||
<div class="col-6">
|
</li>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
<div class="{% if forloop.first %}level-1 row{% elif forloop.counter == 2 %}level-2 row{%endif%}">
|
</ul>
|
||||||
<div class="card my-3 border-{{level.department_colour}}">
|
</li>
|
||||||
<h3 class="card-header"><a href="{% url 'level_detail' level.pk %}">{{ level }}</a></h3>
|
</ul>
|
||||||
<div class="card-body">
|
|
||||||
<p>{{ level.description|markdown }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if forloop.last %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -26,3 +26,8 @@ def percentage_complete(level, user):
|
|||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def colour_from_depth(depth):
|
def colour_from_depth(depth):
|
||||||
return models.TrainingItemQualification.get_colour_from_depth(depth)
|
return models.TrainingItemQualification.get_colour_from_depth(depth)
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def get_supervisor(tech):
|
||||||
|
return models.TrainingLevel.objects.get(department=tech.department, level=models.TrainingLevel.SUPERVISOR)
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ class LevelList(generic.ListView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["page_title"] = "All Training Levels"
|
context["page_title"] = "All Training Levels"
|
||||||
context["levels"] = models.TrainingLevel.objects.all().order_by('level', 'department')
|
context["ta"] = models.TrainingLevel.objects.get(level=models.TrainingLevel.TA)
|
||||||
|
context["tech"] = models.TrainingLevel.objects.filter(level=models.TrainingLevel.TECHNICIAN).order_by('department')
|
||||||
|
context["sup"] = models.TrainingLevel.objects.filter(level=models.TrainingLevel.SUPERVISOR).order_by('department')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user