Various tweaks

This commit is contained in:
2021-09-13 01:07:17 +01:00
parent 75410db752
commit 081c33ebc8
4 changed files with 22 additions and 12 deletions

View File

@@ -10,6 +10,9 @@ class Trainee(Profile):
class Meta:
proxy = True
def started_levels(self):
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0]
def level_qualifications(self, only_confirmed=False):
levels = self.levels.all()
if only_confirmed:
@@ -219,7 +222,7 @@ class TrainingLevelQualification(models.Model):
reversion_hide = True
def __str__(self):
return "{} qualified as a {}".format(self.trainee, self.level)
return "{} is qualified as a {}".format(self.trainee, self.level)
class Meta:
unique_together = ["trainee", "level"]

View File

@@ -53,11 +53,19 @@
</div>
<div class="row mb-3">
<h2 class="col-12">Training Levels</h2>
{% for level in completed_levels %}
{% if forloop.first %}<div class="card-columns">{% endif %}
<div class="card my-3 border-success">
<h3 class="card-header"><a href="{% url 'level_detail' level.pk %}">{{ level }}</a></h3>
</div>
{% if forloop.last %}</div>{%endif%}
{% empty %}
<span class="badge badge-warning">No qualifications in any levels yet...did someone forget to fill out the paperwork?</span>
{% endfor %}
<div class="card-columns">
{% for level in levels %}
{% for level in started_levels %}
{% percentage_complete level object as completion %}
{% if completion > 0 %}
<div class="card my-3">
<div class="card my-3 border-warning">
<h3 class="card-header"><a href="{% url 'level_detail' level.pk %}">{{ level }}</a></h3>
<div class="card-body">
<p>{{ level.description|truncatewords:30 }}</p>
@@ -82,9 +90,6 @@
{% endif %}
</div>
</div>
{% endif %}
{% empty %}
<p class="text-muted">No progress in any levels yet...did someone forget to fill out the paperwork?</p>
{% endfor %}
</div>
</div>

View File

@@ -22,7 +22,7 @@
<tbody>
{% for object in object_list %}
<tr id="row_item">
<th scope="row" class="align-middle" id="cell_name">{{ object.name }} {% if request.user.pk == object.pk %}<span class="fas fa-user text-success"></span>{%endif%}</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_supervisor %}class="table-success"{%endif%}>{{ object.is_supervisor|yesno|title }}</td>
<td>{{ object.qualifications_obtained.all|length }}</td>
<td>

View File

@@ -27,10 +27,12 @@ class TraineeDetail(views.ProfileDetail, ModalURLMixin):
def get_context_data(self, **kwargs):
context = super(TraineeDetail, self).get_context_data(**kwargs)
context["page_title"] = "{}'s Training Record".format(self.object.first_name + " " + self.object.last_name)
# TODO Filter this to levels the user has
# context["completed_levels"] =
context["levels"] = models.TrainingLevel.objects.all()
if self.request.user.pk == self.object.pk:
context["page_title"] = "Your Training Record"
else:
context["page_title"] = "{}'s Training Record".format(self.object.first_name + " " + self.object.last_name)
context["started_levels"] = self.object.started_levels()
context["completed_levels"] = self.object.level_qualifications()
context["categories"] = models.TrainingCategory.objects.all().prefetch_related('items')
choices = models.TrainingItemQualification.CHOICES
context["depths"] = choices