Fix is_supervisor returning true if user has any levels

Whoops!
This commit is contained in:
2022-01-02 11:15:03 +00:00
parent b73b8401b6
commit 046d0e461d
3 changed files with 3 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ class Trainee(Profile, RevisionMixin):
@property
def is_supervisor(self):
return self.level_qualifications.all().exclude(confirmed_on=None).select_related('level') \
.filter(level__gte=TrainingLevel.SUPERVISOR) \
.filter(level__level__gte=TrainingLevel.SUPERVISOR) \
.exclude(level__department=TrainingLevel.HAULAGE) \
.exclude(level__department__isnull=True).exists()

View File

@@ -38,7 +38,7 @@
<td {% if object.is_driver %}class="table-success"{%endif%}>{{ 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 {% 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>{{ object.num_qualifications }}</td>
<td>{{ object.num_qualifications }} {% if forloop.first %} <span class="fas fa-crown text-warning"></span>{% endif %}</td>
<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 href="{% url 'trainee_item_detail' pk=object.pk %}" class="btn btn-info"><span class="fas fa-info-circle"></span> View Detailed Record</a>

View File

@@ -39,4 +39,4 @@ def get_supervisor(tech):
@register.filter
def get_levels_of_depth(trainee, level):
return trainee.level_qualifications.all().exclude(confirmed_on=None).select_related('level').filter(level__level=level)
return trainee.level_qualifications.all().exclude(confirmed_on=None).exclude(level__department=models.TrainingLevel.HAULAGE).select_related('level').filter(level__level=level)