diff --git a/src/registrar/models/contact.py b/src/registrar/models/contact.py index d3de5a293..0b097974e 100644 --- a/src/registrar/models/contact.py +++ b/src/registrar/models/contact.py @@ -93,6 +93,14 @@ class Contact(TimeStampedModel): names = [n for n in [self.first_name, self.middle_name, self.last_name] if n] return " ".join(names) if names else "Unknown" + def has_contact_info(self): + has_contact_info = ( + self.title or + self.email or + self.phone + ) + return has_contact_info + def save(self, *args, **kwargs): # Call the parent class's save method to perform the actual save super().save(*args, **kwargs) diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 1ca2412ca..7e9cdf73e 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -92,6 +92,14 @@ class User(AbstractUser): """Return count of ineligible requests""" return self.domain_requests_created.filter(status=DomainRequest.DomainRequestStatus.INELIGIBLE).count() + def has_contact_info(self): + has_contact_info = ( + self.contact.title or + self.email.title or + self.contact.phone + ) + return has_contact_info + @classmethod def needs_identity_verification(cls, email, uuid): """A method used by our oidc classes to test whether a user needs email/uuid verification diff --git a/src/registrar/templates/django/admin/includes/contact_detail_list.html b/src/registrar/templates/django/admin/includes/contact_detail_list.html index b5ccb5a42..0ac9c4c49 100644 --- a/src/registrar/templates/django/admin/includes/contact_detail_list.html +++ b/src/registrar/templates/django/admin/includes/contact_detail_list.html @@ -1,6 +1,6 @@ {% load i18n static %} -
+ {% if show_formatted_name %} {% if contact.get_formatted_name %} @@ -10,7 +10,7 @@ {% endif %} {% endif %} - {% if user.title or user.contact.title or user.email or user.contact.email or user.phone or user.contact.phone %} + {% if user.has_contact_info %} {# Title #} {% if user.title or user.contact.title %} {% if user.contact.title %}