From f40ef08cba4d63dbba69ef0e602fabe97b445b24 Mon Sep 17 00:00:00 2001 From: asaki222 Date: Fri, 1 Nov 2024 19:14:38 -0400 Subject: [PATCH] changes so far --- src/registrar/admin.py | 20 +++++++++++++++++--- src/registrar/tests/test_admin_request.py | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index b08eabc29..444acae37 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1766,7 +1766,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): "Contacts", { "fields": [ - "converted_senior_official", + "display_converted_senior_official", "other_contacts", "no_other_contacts_rationale", "cisa_representative_first_name", @@ -1832,7 +1832,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): "alternative_domains", "is_election_board", "status_history", - "converted_senior_official", + "display_converted_senior_official", "converted_federal_type", "converted_federal_agency", "converted_state_territory", @@ -1865,7 +1865,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): "approved_domain", "requested_domain", "creator", - "senior_official", "investigator", "portfolio", "sub_organization", @@ -1879,6 +1878,21 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): change_form_template = "django/admin/domain_request_change_form.html" + def display_converted_senior_official(self, obj): + so = obj.converted_senior_official + if so: + parts = [] + if so.first_name or so.last_name: + full_name = f"{so.first_name or ''} {so.last_name or ''}".strip() + parts.append(full_name) + if so.title: + parts.append(so.title) + if so.email: + parts.append(so.email) + if so.phone: + parts.append(str(so.phone)) + return "\n\n".join(parts) if parts else "N/A" + # Trigger action when a fieldset is changed def save_model(self, request, obj, form, change): """Custom save_model definition that handles edge cases""" diff --git a/src/registrar/tests/test_admin_request.py b/src/registrar/tests/test_admin_request.py index 5c3f01787..55e945869 100644 --- a/src/registrar/tests/test_admin_request.py +++ b/src/registrar/tests/test_admin_request.py @@ -1508,6 +1508,8 @@ class TestDomainRequestAdmin(MockEppLib): self.assertContains(response, "Meoward Jones") # == Check for the senior_official == # + print("SENIOR OFFICIAL") + print(response.content.decode("utf-8")) self.assertContains(response, "testy@town.com", count=2) expected_so_fields = [ # Field, expected value