From 788561f7445c56f611b0cb15bcc394cfb59983a5 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 27 Feb 2024 07:16:58 -0500 Subject: [PATCH 1/2] investigators list in filter shows only distinct values --- src/registrar/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 86234431d..12c9d67cc 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -844,7 +844,7 @@ def lookups(self, request, model_admin): "investigator__email", output_field=CharField(), ) - ).values_list("investigator__id", "full_name") + ).values_list("investigator__id", "full_name").distinct() return privileged_users_annotated From 52824c75c6f5ef5196d325027c6c174c6c94bea1 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 27 Feb 2024 07:27:53 -0500 Subject: [PATCH 2/2] formatting for linter --- src/registrar/admin.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 12c9d67cc..0b7553c30 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -838,13 +838,19 @@ def lookups(self, request, model_admin): ) # Annotate the full name and return a values list that lookups can use - privileged_users_annotated = privileged_users.annotate( - full_name=Coalesce( - Concat("investigator__first_name", Value(" "), "investigator__last_name", output_field=CharField()), - "investigator__email", - output_field=CharField(), + privileged_users_annotated = ( + privileged_users.annotate( + full_name=Coalesce( + Concat( + "investigator__first_name", Value(" "), "investigator__last_name", output_field=CharField() + ), + "investigator__email", + output_field=CharField(), + ) ) - ).values_list("investigator__id", "full_name").distinct() + .values_list("investigator__id", "full_name") + .distinct() + ) return privileged_users_annotated