simplified contact detail list template

This commit is contained in:
David Kennedy 2024-04-12 10:47:12 -04:00
parent 41406a76ea
commit 1fa0e63126
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 18 additions and 2 deletions

View file

@ -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)

View file

@ -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

View file

@ -1,6 +1,6 @@
{% load i18n static %}
<address class="{% if no_title_top_padding %}margin-top-neg-1__detail-list{% endif %} {% if user.title or user.contact.title or user.email or user.contact.email or user.phone or user.contact.phone %}margin-bottom-1{% endif %} dja-address-contact-list">
<address class="{% if no_title_top_padding %}margin-top-neg-1__detail-list{% endif %} {% if user.has_contact_info %}margin-bottom-1{% endif %} dja-address-contact-list">
{% 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 %}