Add last resort

This commit is contained in:
zandercymatics 2023-12-14 12:25:14 -07:00
parent 66a5af08eb
commit de82da6e78
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -666,12 +666,17 @@ class DomainAddUserView(DomainFormBaseView):
# want to fix this upstream where it is happening. # want to fix this upstream where it is happening.
raise ValueError("Can't send email. The given DomainInformation object has no requestor or creator.") raise ValueError("Can't send email. The given DomainInformation object has no requestor or creator.")
# Attempt to grab the first and last names. As a last resort, just use the email.
if first and last: if first and last:
full_name = f"{first} {last}" full_name = f"{first} {last}"
elif requester.email is not None and requester.email.strip() != "":
full_name = requester.email
elif domainInfo.creator.email is not None and domainInfo.creator.email.strip() != "":
full_name = domainInfo.creator.email
else: else:
# This edgecase would be unusual if encountered. We don't want to handle this here. Rather, we would # This edgecase would be unusual if encountered. We don't want to handle this here. Rather, we would
# want to fix this upstream where it is happening. # want to fix this upstream where it is happening.
raise ValueError("Can't send email. First and last names are none.") raise ValueError("Can't send email. First and last names, as well as the email, are none.")
try: try:
send_templated_email( send_templated_email(