update trainees page
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<a href='{% url "trainees" %}'>All, </a>
|
||||
{% for i in "123456"|make_list %}
|
||||
<a href='{% url "trainees_grade" "ST"|add:i %}'>ST{{i}}</a>{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<h2>
|
||||
{% if grade %}
|
||||
@@ -12,14 +16,14 @@
|
||||
{% endif %}Trainees
|
||||
</h2>
|
||||
<table>
|
||||
<tr class="header"><th>Name</th><th>Grade</th><th>Email</th><th>Supervisor</th></tr>
|
||||
<tr class="header"><th>Name</th><th>Grade</th><th>Email</th><th>Supervisor</th><th>Edit</th></tr>
|
||||
|
||||
{% for trainee in trainees %}
|
||||
<tr class="trainee"><td>{{trainee.user.first_name}} {{trainee.user.last_name}}</td><td>{{trainee.grade}}</td><td>{{trainee.user.email}}</td><td>{{trainee.supervisor}}</td></tr>
|
||||
<tr class="trainee"><td>{{trainee.user.first_name}} {{trainee.user.last_name}}</td><td>{{trainee.grade}}</td><td>{{trainee.user.email}}</td><td>{{trainee.supervisor}}</td><td><a href="{% url 'account_update' trainee.user.username %}">User</a>/<a href="{% url 'account_profile_update' trainee.user.username %}">Profile</a></td></tr>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<div class="small-gray">Count: {{trainees|length}}</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ from dal import autocomplete
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.forms.models import model_to_dict
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.db.models.functions import Coalesce, Lower
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
|
||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||
@@ -3034,7 +3034,7 @@ def exam_inactive(request, context):
|
||||
@user_is_cid_user_manager
|
||||
def trainees(request, grade: None|str=None):
|
||||
|
||||
trainees = UserProfile.objects.filter(peninsula_trainee=True).order_by(Coalesce("grade__name", "user__last_name").asc())
|
||||
trainees = UserProfile.objects.filter(peninsula_trainee=True, user__is_active=True).order_by("grade__name", Lower("user__last_name"))
|
||||
|
||||
if grade is not None:
|
||||
trainees = trainees.filter(grade__name=grade)
|
||||
|
||||
Reference in New Issue
Block a user