From aa8e34c899af80b58f70bf7c129dc9debaa18d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org> Date: Tue, 17 Oct 2023 15:32:35 +0200 Subject: [PATCH] Debug display of fellowship type in detail; accelerate with prefetch --- .../templates/colleges/fellowship_detail.html | 20 +++++++++++++++++-- scipost_django/colleges/views.py | 7 +++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scipost_django/colleges/templates/colleges/fellowship_detail.html b/scipost_django/colleges/templates/colleges/fellowship_detail.html index b60965639..4694a11c6 100644 --- a/scipost_django/colleges/templates/colleges/fellowship_detail.html +++ b/scipost_django/colleges/templates/colleges/fellowship_detail.html @@ -54,7 +54,15 @@ </tr> <tr> <th>Type</th> - <td>{{ fellowship.guest|yesno:"Guest fellowship,Regular fellowship"|safe }}</td> + <td> + {% if fellowship.guest %} + <span class="text-warning">Guest</span> + {% elif fellowship.senior %} + <span class="text-success">Senior</span> + {% else %} + <span class="text-primary">Regular</span> + {% endif %} +` </td> </tr> </tbody> </table> @@ -87,7 +95,15 @@ {% for fship in fellowship.sibling_fellowships %} <tr> <td>{{ fship.id }}</td> - <td>{{ fship.guest|yesno:"Guest fellowship,Regular fellowship"|safe }}</td> + <td> + {% if fship.guest %} + <span class="text-warning">Guest</span> + {% elif fship.senior %} + <span class="text-success">Senior</span> + {% else %} + <span class="text-primary">Regular</span> + {% endif %} + </td> <td> {% if fship.start_date %} from {{ fship.start_date }} diff --git a/scipost_django/colleges/views.py b/scipost_django/colleges/views.py index 1e78d148a..6a1384db8 100644 --- a/scipost_django/colleges/views.py +++ b/scipost_django/colleges/views.py @@ -201,6 +201,13 @@ class FellowshipDetailView(PermissionsMixin, DetailView): permission_required = "scipost.can_manage_college_composition" model = Fellowship + def get_queryset(self): + queryset = Fellowship.objects.all().prefetch_related( + "pool__preprint", + "pool__editor_in_charge", + ) + return queryset + class FellowshipListView(PermissionsMixin, PaginationMixin, ListView): """ -- GitLab