mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-25 17:32:16 +00:00
Various tweaks
This commit is contained in:
@@ -10,6 +10,9 @@ class Trainee(Profile):
|
|||||||
class Meta:
|
class Meta:
|
||||||
proxy = True
|
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):
|
def level_qualifications(self, only_confirmed=False):
|
||||||
levels = self.levels.all()
|
levels = self.levels.all()
|
||||||
if only_confirmed:
|
if only_confirmed:
|
||||||
@@ -219,7 +222,7 @@ class TrainingLevelQualification(models.Model):
|
|||||||
reversion_hide = True
|
reversion_hide = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} qualified as a {}".format(self.trainee, self.level)
|
return "{} is qualified as a {}".format(self.trainee, self.level)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ["trainee", "level"]
|
unique_together = ["trainee", "level"]
|
||||||
|
|||||||
@@ -53,11 +53,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<h2 class="col-12">Training Levels</h2>
|
<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">
|
<div class="card-columns">
|
||||||
{% for level in levels %}
|
{% for level in started_levels %}
|
||||||
{% percentage_complete level object as completion %}
|
{% percentage_complete level object as completion %}
|
||||||
{% if completion > 0 %}
|
<div class="card my-3 border-warning">
|
||||||
<div class="card my-3">
|
|
||||||
<h3 class="card-header"><a href="{% url 'level_detail' level.pk %}">{{ level }}</a></h3>
|
<h3 class="card-header"><a href="{% url 'level_detail' level.pk %}">{{ level }}</a></h3>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p>{{ level.description|truncatewords:30 }}</p>
|
<p>{{ level.description|truncatewords:30 }}</p>
|
||||||
@@ -82,9 +90,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% empty %}
|
|
||||||
<p class="text-muted">No progress in any levels yet...did someone forget to fill out the paperwork?</p>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% 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">{{ 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 {% if object.is_supervisor %}class="table-success"{%endif%}>{{ object.is_supervisor|yesno|title }}</td>
|
||||||
<td>{{ object.qualifications_obtained.all|length }}</td>
|
<td>{{ object.qualifications_obtained.all|length }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ class TraineeDetail(views.ProfileDetail, ModalURLMixin):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(TraineeDetail, self).get_context_data(**kwargs)
|
context = super(TraineeDetail, self).get_context_data(**kwargs)
|
||||||
context["page_title"] = "{}'s Training Record".format(self.object.first_name + " " + self.object.last_name)
|
if self.request.user.pk == self.object.pk:
|
||||||
# TODO Filter this to levels the user has
|
context["page_title"] = "Your Training Record"
|
||||||
# context["completed_levels"] =
|
else:
|
||||||
context["levels"] = models.TrainingLevel.objects.all()
|
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')
|
context["categories"] = models.TrainingCategory.objects.all().prefetch_related('items')
|
||||||
choices = models.TrainingItemQualification.CHOICES
|
choices = models.TrainingItemQualification.CHOICES
|
||||||
context["depths"] = choices
|
context["depths"] = choices
|
||||||
|
|||||||
Reference in New Issue
Block a user