Merge pull request #2030 from cisagov/dk/1922-add-user-column

Issue #1922: Added column that indicates whether Contact is also a User
This commit is contained in:
dave-kennedy-ecs 2024-04-16 14:14:19 -04:00 committed by GitHub
commit 81c47c2eb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -663,6 +663,7 @@ class ContactAdmin(ListHeaderAdmin):
list_display = [ list_display = [
"contact", "contact",
"email", "email",
"user_exists",
] ]
# this ordering effects the ordering of results # this ordering effects the ordering of results
# in autocomplete_fields for user # in autocomplete_fields for user
@ -679,6 +680,13 @@ class ContactAdmin(ListHeaderAdmin):
change_form_template = "django/admin/email_clipboard_change_form.html" change_form_template = "django/admin/email_clipboard_change_form.html"
def user_exists(self, obj):
"""Check if the Contact has a related User"""
return "Yes" if obj.user is not None else "No"
user_exists.short_description = "Is user" # type: ignore
user_exists.admin_order_field = "user" # type: ignore
# We name the custom prop 'contact' because linter # We name the custom prop 'contact' because linter
# is not allowing a short_description attr on it # is not allowing a short_description attr on it
# This gets around the linter limitation, for now. # This gets around the linter limitation, for now.