removed user from contact model and all associated logic

This commit is contained in:
David Kennedy 2024-07-02 16:59:18 -04:00
parent 5f5e487eb0
commit 45c7f1aaa6
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
10 changed files with 67 additions and 459 deletions

View file

@ -593,12 +593,6 @@ class ListHeaderAdmin(AuditedAdmin, OrderableFieldsMixin):
return filters
class UserContactInline(admin.StackedInline):
"""Edit a user's profile on the user page."""
model = models.Contact
class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
"""Custom user admin class to use our inlines."""
@ -615,8 +609,6 @@ class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
_meta = Meta()
inlines = [UserContactInline]
list_display = (
"username",
"overridden_email_field",
@ -894,30 +886,20 @@ class ContactAdmin(ListHeaderAdmin, ImportExportModelAdmin):
list_display = [
"name",
"email",
"user_exists",
]
# this ordering effects the ordering of results
# in autocomplete_fields for user
# in autocomplete_fields
ordering = ["first_name", "last_name", "email"]
fieldsets = [
(
None,
{"fields": ["user", "first_name", "middle_name", "last_name", "title", "email", "phone"]},
{"fields": ["first_name", "middle_name", "last_name", "title", "email", "phone"]},
)
]
autocomplete_fields = ["user"]
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
# is not allowing a short_description attr on it
# This gets around the linter limitation, for now.
@ -935,9 +917,7 @@ class ContactAdmin(ListHeaderAdmin, ImportExportModelAdmin):
name.admin_order_field = "first_name" # type: ignore
# Read only that we'll leverage for CISA Analysts
analyst_readonly_fields = [
"user",
]
analyst_readonly_fields = []
def get_readonly_fields(self, request, obj=None):
"""Set the read-only state on form elements.