Do not display qualified levels also as started

This commit is contained in:
2022-01-02 10:34:04 +00:00
parent 70d4c42676
commit 22dc83d595
3 changed files with 20 additions and 13 deletions

View File

@@ -12,10 +12,9 @@ class Trainee(Profile, RevisionMixin):
class Meta: class Meta:
proxy = True proxy = True
# TODO remove levels that the user has a qualification in
# FIXME use queryset # FIXME use queryset
def started_levels(self): def started_levels(self):
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0] 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 @property
def is_supervisor(self): def is_supervisor(self):
@@ -109,6 +108,9 @@ class TrainingItemQualification(models.Model):
else: else:
return "info" return "info"
def get_absolute_url(self):
return reverse('trainee_item_detail', kwargs={'pk': self.trainee.pk})
class Meta: class Meta:
unique_together = ["trainee", "item", "depth"] unique_together = ["trainee", "item", "depth"]
order_with_respect_to = 'item' order_with_respect_to = 'item'

View File

@@ -96,6 +96,9 @@
<div class="card mb-3 d-none d-md-block"> <div class="card mb-3 d-none d-md-block">
<h4 class="card-header">Users with this level</h4> <h4 class="card-header">Users with this level</h4>
<div class="card-body"> <div class="card-body">
{% for user in users_with %}
{% user_level_if_present user object as level_qualification %}
{% if forloop.first %}
<table class="table table-sm"> <table class="table table-sm">
<thead> <thead>
<tr> <tr>
@@ -105,18 +108,19 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for user in users_with %} {% endif %}
{% user_level_if_present user object as level_qualification %} <tr {% if not level_qualification.confirmed_on %}style="border-style: dashed; opacity: 80%"{%endif%}>
<tr {% if not level_qualification.confirmed_on %}style="border-style: dashed; opacity: 80%"{%endif%}> <td><img src="{{user.profile_picture}}" style="width: 50px" class="img-thumbnail"/> {{user}}</td>
<td><img src="{{user.profile_picture}}" style="width: 50px" class="img-thumbnail"/> {{user}}</td> <td>{% if level_qualification.confirmed_on %}<p class="card-text"><small>Qualified on {{ level_qualification.confirmed_on }}</small></p>{%else%}Unconfirmed{%endif%}</td>
<td>{% if level_qualification.confirmed_on %}<p class="card-text"><small>Qualified on {{ level_qualification.confirmed_on }}</small></p>{%else%}Unconfirmed{%endif%}</td> <td><a href="{% url 'profile_detail' user.pk %}" class="btn btn-primary btn-sm"><span class="fas fa-user"></span> View Profile</a></div></td>
<td><a href="{% url 'profile_detail' user.pk %}" class="btn btn-primary btn-sm"><span class="fas fa-user"></span> View Profile</a></div></td> </tr>
</tr> {% if forloop.last %}
{% empty %}
Nobody here but us chickens... <span class="fas fa-egg text-warning"></span>
{% endfor %}
</tbody> </tbody>
</table> </table>
{% endif %}
{% empty %}
Nobody here but us chickens... <span class="fas fa-egg text-warning"></span>
{% endfor %}
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@@ -51,7 +51,8 @@ class TraineeItemDetail(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"] = "Detailed Training Record for {}".format(models.Trainee.objects.get(pk=self.kwargs['pk'])) trainee = models.Trainee.objects.get(pk=self.kwargs['pk'])
context["page_title"] = "Detailed Training Record for <a href='{}'>{}</a>".format(trainee.get_absolute_url(), trainee)
return context return context