FEAT(T): Add ability to view users passed out in a certain training item

This commit is contained in:
2022-03-03 19:30:31 +00:00
parent 23e17b0e34
commit 00eb4e0e27
4 changed files with 66 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
</ul>
</div>
{% endif %}
<a href="{% url 'item_qualification' item.pk %}" class="btn btn-info"><span class="fas fa-user"></span> Qualified Users</a>
</li>
{% endfor %}
</div>

View File

@@ -0,0 +1,49 @@
{% extends 'base_training.html' %}
{% load paginator from filters %}
{% load colour_from_depth from tags %}
{% load static %}
{% block js %}
<script src="{% static "js/tooltip.js" %}"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
{% endblock %}
{% block content %}
<div class="row pt-2">
<div class="col">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th>Level</th>
<th>Date</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr id="row_item">
<th scope="row" class="align-middle" id="cell_name"><a href="{% url 'trainee_detail' object.trainee.pk %}">{{ object.trainee }} {% if request.user.pk == object.trainee.pk %}<span class="fas fa-user text-success"></span>{%endif%}</a></th>
<td class="table-{% colour_from_depth object.depth %}">{{ object.get_depth_display }}</td>
<td>{{ object.date }}</td>
<td>{{ object.notes }}</td>
</tr>
{% empty %}
<tr class="table-warning">
<td colspan="6" class="text-center">Nothing found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% paginator %}
{% endblock %}

View File

@@ -8,6 +8,8 @@ from versioning.views import VersionHistory
urlpatterns = [
path('items/', login_required(views.ItemList.as_view()), name='item_list'),
path('item/<int:pk>/qualified_users/', login_required(views.ItemQualifications.as_view()), name='item_qualification'),
path('trainee/list/', login_required(views.TraineeList.as_view()), name='trainee_list'),
path('trainee/<int:pk>/',
has_perm_or_supervisor('RIGS.view_profile')(views.TraineeDetail.as_view()),

View File

@@ -236,3 +236,17 @@ class SessionLog(generic.FormView):
context["page_title"] = "Log Training Session"
get_related(context['form'], context)
return context
class ItemQualifications(generic.ListView):
template_name = "item_qualification_list.html"
model = models.TrainingItemQualification
paginate_by = 40
def get_queryset(self):
return models.TrainingItemQualification.objects.filter(item=self.kwargs['pk']).order_by('-depth').select_related('trainee')
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_title"] = f"People Qualified In {self.object_list[0].item}"
return context