mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 16:32:15 +00:00
Various fixes
This commit is contained in:
@@ -16,9 +16,17 @@ class Trainee(Profile, RevisionMixin):
|
|||||||
def started_levels(self):
|
def started_levels(self):
|
||||||
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0 and level.pk not in self.level_qualifications.values_list('level', flat=True)]
|
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0 and level.pk not in self.level_qualifications.values_list('level', flat=True)]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_technician(self):
|
||||||
|
return self.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
||||||
|
.filter(level__level=TrainingLevel.TECHNICIAN) \
|
||||||
|
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||||
|
.exclude(level__department__isnull=True).exists()
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_supervisor(self):
|
def is_supervisor(self):
|
||||||
return self.level_qualifications.all().exclude(confirmed_on=None).select_related('level') \
|
return self.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
||||||
.filter(level__level__gte=TrainingLevel.SUPERVISOR) \
|
.filter(level__level__gte=TrainingLevel.SUPERVISOR) \
|
||||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||||
.exclude(level__department__isnull=True).exists()
|
.exclude(level__department__isnull=True).exists()
|
||||||
@@ -66,7 +74,7 @@ class TrainingItem(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def user_has_qualification(item, user, depth):
|
def user_has_qualification(item, user, depth):
|
||||||
return user.qualifications_obtained.values('item', 'depth').filter(item=item, depth__gte=depth).exists()
|
return user.qualifications_obtained.only('item', 'depth').filter(item=item, depth__gte=depth).exists()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ["reference_number", "active", "category"]
|
unique_together = ["reference_number", "active", "category"]
|
||||||
@@ -211,6 +219,14 @@ class TrainingLevel(models.Model, RevisionMixin):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('level_detail', kwargs={'pk': self.pk})
|
return reverse('level_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_icon(self):
|
||||||
|
if self.icon is not None:
|
||||||
|
icon = "<span class='fas fa-{}'></span>".format(self.icon)
|
||||||
|
else:
|
||||||
|
icon = "".join([w[0] for w in str(self).split()])
|
||||||
|
return mark_safe("<span class='badge badge-{} badge-pill' data-toggle='tooltip' title='{}'>{}</span>".format(self.department_colour, str(self), icon))
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
class TrainingLevelRequirement(models.Model, RevisionMixin):
|
class TrainingLevelRequirement(models.Model, RevisionMixin):
|
||||||
@@ -238,11 +254,7 @@ class TrainingLevelQualification(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def get_icon(self):
|
def get_icon(self):
|
||||||
if self.level.icon is not None:
|
return self.level.get_icon
|
||||||
icon = "<span class='fas fa-{}'></span>".format(self.level.icon)
|
|
||||||
else:
|
|
||||||
icon = "".join([w[0] for w in str(self.level).split()])
|
|
||||||
return mark_safe("<span class='badge badge-{} badge-pill' data-toggle='tooltip' title='{}'>{}</span>".format(self.level.department_colour, self.level, icon))
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.level.is_common_competencies:
|
if self.level.is_common_competencies:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
{% if item.active %}
|
{% if item.active %}
|
||||||
<li class="list-group-item">{{ item }}</li>
|
<li class="list-group-item">{{ item }}</li>
|
||||||
{% elif request.user.is_superuser %}
|
{% elif request.user.is_superuser %}
|
||||||
<li class="list-group-item text-warning">{{ item }} (inactive)</li>
|
<li class="list-group-item text-warning">{{ item }}</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,9 +35,9 @@
|
|||||||
{% for object in object_list %}
|
{% for object in object_list %}
|
||||||
<tr id="row_item">
|
<tr id="row_item">
|
||||||
<th scope="row" class="align-middle" id="cell_name"><a href="{% url 'trainee_detail' object.pk %}">{{ object.name }} {% if request.user.pk == object.pk %}<span class="fas fa-user text-success"></span>{%endif%}</a></th>
|
<th scope="row" class="align-middle" id="cell_name"><a href="{% url 'trainee_detail' object.pk %}">{{ object.name }} {% if request.user.pk == object.pk %}<span class="fas fa-user text-success"></span>{%endif%}</a></th>
|
||||||
<td {% if object.is_driver %}class="table-success"{%endif%}>{{ object.is_driver|yesno|title }}</td>
|
<td>{{ object.is_driver|yesno|title }}</td>
|
||||||
<td>{% for level in object|get_levels_of_depth:1 %}{% if forloop.first %}Yes {%endif%}{{ level.get_icon }}{%empty%}No{%endfor%}</td>
|
<td>{% for level in object|get_levels_of_depth:1 %}{% if forloop.first %}Yes {%endif%}{{ level.get_icon }}{%empty%}No{%endfor%}</td>
|
||||||
<td {% if object.is_supervisor %}class="table-success"{%endif%}>{% for level in object|get_levels_of_depth:2 %}{% if forloop.first %}Yes {%endif%}{{ level.get_icon }}{%empty%}No{%endfor%}</td>
|
<td>{% for level in object|get_levels_of_depth:2 %}{% if forloop.first %}Yes {%endif%}{{ level.get_icon }}{%empty%}No{%endfor%}</td>
|
||||||
<td>{{ object.num_qualifications }} {% if forloop.first %} <span class="fas fa-crown text-warning"></span>{% endif %}</td>
|
<td>{{ object.num_qualifications }} {% if forloop.first %} <span class="fas fa-crown text-warning"></span>{% endif %}</td>
|
||||||
<td style="white-space: nowrap">
|
<td style="white-space: nowrap">
|
||||||
<a class="btn btn-info" href="{% url 'trainee_detail' pk=object.pk %}"><span class="fas fa-eye"></span> View Training Record</a>
|
<a class="btn btn-info" href="{% url 'trainee_detail' pk=object.pk %}"><span class="fas fa-eye"></span> View Training Record</a>
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ register = template.Library()
|
|||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def user_has_qualification(user, item, depth):
|
def user_has_qualification(user, item, depth):
|
||||||
if models.TrainingItem.user_has_qualification(item, user, depth) is not None:
|
if models.TrainingItem.user_has_qualification(item, user, depth):
|
||||||
return mark_safe("<span class='fas fa-check text-success'></span>")
|
return mark_safe("<span class='fas fa-check text-success' title='You have this requirement'></span>")
|
||||||
else:
|
else:
|
||||||
return mark_safe("<span class='fas fa-hourglass-start text-warning'></span>")
|
return mark_safe("<span class='fas fa-hourglass-start text-warning' title='You do not yet have this requirement'></span>")
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class LevelDetail(generic.DetailView):
|
|||||||
|
|
||||||
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"] = "Training Level {} <span class='badge badge-{} badge-pill'><span class='fas fa-{}'></span></span>".format(self.object, self.object.department_colour, self.object.icon)
|
context["page_title"] = "Training Level {} {}".format(self.object, self.object.get_icon)
|
||||||
context["users_with"] = map(lambda qual: qual.trainee, models.TrainingLevelQualification.objects.filter(level=self.object))
|
context["users_with"] = map(lambda qual: qual.trainee, models.TrainingLevelQualification.objects.filter(level=self.object))
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user