From 2ffeda3be7340e9294f9ece9f0cd2d3892a19281 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 15 Apr 2024 07:46:07 -0400 Subject: [PATCH 1/6] added column for Is user to Contact table in DJA --- src/registrar/admin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 05bfc06b6..5116888dd 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -663,6 +663,7 @@ class ContactAdmin(ListHeaderAdmin): list_display = [ "contact", "email", + "user_exists", ] # this ordering effects the ordering of results # in autocomplete_fields for user @@ -679,6 +680,12 @@ class ContactAdmin(ListHeaderAdmin): change_form_template = "django/admin/email_clipboard_change_form.html" + def user_exists(self, obj): + """Check if the Contact has a related User""" + return obj.user is not None + user_exists.boolean = True + user_exists.short_description = "Is user" + # We name the custom prop 'contact' because linter # is not allowing a short_description attr on it # This gets around the linter limitation, for now. From 3909ba8212fdb9c7643af59f25d43d45c58defee Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 15 Apr 2024 07:53:24 -0400 Subject: [PATCH 2/6] formatted for readability --- src/registrar/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 5116888dd..b9114f6f5 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -683,6 +683,7 @@ class ContactAdmin(ListHeaderAdmin): def user_exists(self, obj): """Check if the Contact has a related User""" return obj.user is not None + user_exists.boolean = True user_exists.short_description = "Is user" From 77d2c998d3d62d15fdab6c581ef9ad049d7cb4b4 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 15 Apr 2024 07:57:34 -0400 Subject: [PATCH 3/6] satisfying linter --- src/registrar/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index b9114f6f5..fe0730d31 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -684,8 +684,8 @@ class ContactAdmin(ListHeaderAdmin): """Check if the Contact has a related User""" return obj.user is not None - user_exists.boolean = True - user_exists.short_description = "Is user" + user_exists.boolean = True # type: ignore + user_exists.short_description = "Is user" # type: ignore # We name the custom prop 'contact' because linter # is not allowing a short_description attr on it From 69c665e4fa893e6cb60f580ca1d32a3b49370ead Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 16 Apr 2024 11:12:17 -0400 Subject: [PATCH 4/6] made is_user column sortable --- src/registrar/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index fe0730d31..f17aaf1b2 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -686,6 +686,7 @@ class ContactAdmin(ListHeaderAdmin): user_exists.boolean = True # type: ignore user_exists.short_description = "Is user" # type: ignore + user_exists.admin_order_field = 'user' # type: ignore # We name the custom prop 'contact' because linter # is not allowing a short_description attr on it From 72a816acdafc1f2f0e5f875d62dd8ac97fe2105d Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 16 Apr 2024 11:13:17 -0400 Subject: [PATCH 5/6] reformatted --- 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 f17aaf1b2..17486e983 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -686,7 +686,7 @@ class ContactAdmin(ListHeaderAdmin): user_exists.boolean = True # type: ignore user_exists.short_description = "Is user" # type: ignore - user_exists.admin_order_field = 'user' # type: ignore + user_exists.admin_order_field = "user" # type: ignore # We name the custom prop 'contact' because linter # is not allowing a short_description attr on it From ee961c9cd801c876e950bdca5bb4d7c90deb4b5f Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 16 Apr 2024 12:52:48 -0400 Subject: [PATCH 6/6] changed icon to text for column --- src/registrar/admin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 17486e983..b61b21f87 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -682,9 +682,8 @@ class ContactAdmin(ListHeaderAdmin): def user_exists(self, obj): """Check if the Contact has a related User""" - return obj.user is not None + return "Yes" if obj.user is not None else "No" - user_exists.boolean = True # type: ignore user_exists.short_description = "Is user" # type: ignore user_exists.admin_order_field = "user" # type: ignore