From 5952e14ff83a94dd803e7675482f4feeb0181b0e Mon Sep 17 00:00:00 2001 From: Cameron Pitsch Date: Wed, 24 Jul 2024 12:50:05 -0400 Subject: [PATCH 1/3] Change training application ordering criteria First sort by application time, then by credentialed status --- physionet-django/console/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physionet-django/console/views.py b/physionet-django/console/views.py index 7311353de..2f46041de 100644 --- a/physionet-django/console/views.py +++ b/physionet-django/console/views.py @@ -1790,7 +1790,7 @@ def training_list(request, status): List all training applications. """ trainings = Training.objects.select_related( - 'user__profile', 'training_type').order_by('-user__is_credentialed', 'application_datetime') + 'user__profile', 'training_type').order_by('application_datetime', '-user__is_credentialed') training_types = TrainingType.objects.values_list("name", flat=True) From c18595e66ac76aae7c85409b2ff915cc709f36b8 Mon Sep 17 00:00:00 2001 From: Cameron Pitsch Date: Wed, 24 Jul 2024 13:44:30 -0400 Subject: [PATCH 2/3] Update training application ordering criteria First order by date, then by credentialed status, then by time. Like this, the applications can be handled by the day they came in, while still handling applications of credentialed users (those where an accepted training is immediately useful) first. --- physionet-django/console/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/physionet-django/console/views.py b/physionet-django/console/views.py index 2f46041de..2b28f9d55 100644 --- a/physionet-django/console/views.py +++ b/physionet-django/console/views.py @@ -18,7 +18,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.redirects.models import Redirect from django.db.models import Count, DurationField, F, Q -from django.db.models.functions import Cast +from django.db.models.functions import Cast, TruncDate from django.forms import Select, Textarea, modelformset_factory from django.forms.models import model_to_dict from django.http import Http404, HttpResponse, JsonResponse, HttpResponseRedirect @@ -1790,7 +1790,10 @@ def training_list(request, status): List all training applications. """ trainings = Training.objects.select_related( - 'user__profile', 'training_type').order_by('application_datetime', '-user__is_credentialed') + 'user__profile', 'training_type' + ).annotate( + application_date = TruncDate('application_datetime') + ).order_by('application_date', '-user__is_credentialed', 'application_datetime') training_types = TrainingType.objects.values_list("name", flat=True) From 030ffba71fca5b7b8037ccbfae2b6b718f93f313 Mon Sep 17 00:00:00 2001 From: Cameron Pitsch Date: Wed, 24 Jul 2024 14:26:34 -0400 Subject: [PATCH 3/3] Training application sorting: Formatting --- physionet-django/console/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/physionet-django/console/views.py b/physionet-django/console/views.py index 2b28f9d55..c0dbb38d1 100644 --- a/physionet-django/console/views.py +++ b/physionet-django/console/views.py @@ -1789,11 +1789,11 @@ def training_list(request, status): """ List all training applications. """ - trainings = Training.objects.select_related( - 'user__profile', 'training_type' - ).annotate( - application_date = TruncDate('application_datetime') - ).order_by('application_date', '-user__is_credentialed', 'application_datetime') + trainings = ( + Training.objects.select_related("user__profile", "training_type") + .annotate(application_date=TruncDate("application_datetime")) + .order_by("application_date", "-user__is_credentialed", "application_datetime") + ) training_types = TrainingType.objects.values_list("name", flat=True)