mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-19 06:22:16 +00:00
SQL optimisation of detailed training record
This commit is contained in:
@@ -67,7 +67,10 @@ class TrainingItem(models.Model):
|
||||
return "{}.{}".format(self.category.reference_number, self.reference_number)
|
||||
|
||||
def __str__(self):
|
||||
return "{} {}".format(self.number, self.name)
|
||||
name = "{} {}".format(self.number, self.name)
|
||||
if not self.active:
|
||||
name += " (inactive)"
|
||||
return name
|
||||
|
||||
@staticmethod
|
||||
def user_has_qualification(item, user, depth):
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for object in object_list %}
|
||||
<tr id="row_item">
|
||||
<tr id="row_item" {% if request.user.is_superuser and not object.item.active %}class="text-warning"{%endif%}>
|
||||
<th scope="row" class="align-middle" id="cell_name">{{ object.item }}</th>
|
||||
<td class="table-{% colour_from_depth object.depth %}">{{ object.get_depth_display }}</td>
|
||||
<td>{{ object.date }}</td>
|
||||
|
||||
@@ -51,7 +51,7 @@ class TraineeItemDetail(generic.ListView):
|
||||
template_name = 'trainee_item_list.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return models.Trainee.objects.get(pk=self.kwargs['pk']).qualifications_obtained.all()
|
||||
return models.Trainee.objects.get(pk=self.kwargs['pk']).qualifications_obtained.all().order_by('-date').select_related('item', 'trainee', 'supervisor', 'item__category')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user