domain invitations now send email from django admin for both domain and portfolio invitations, consolidated error handling

This commit is contained in:
David Kennedy 2025-01-07 17:04:02 -05:00
parent ab491d1507
commit c2d17442f8
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
6 changed files with 264 additions and 179 deletions

View file

@ -46,8 +46,17 @@ class AlreadyDomainInvitedError(InvitationError):
class MissingEmailError(InvitationError):
"""Raised when the requestor has no email associated with their account."""
def __init__(self):
super().__init__("Can't send invitation email. No email is associated with your user account.")
def __init__(self, email=None, domain=None, portfolio=None):
# Default message if no additional info is provided
message = "Can't send invitation email. No email is associated with your user account."
# Customize message based on provided arguments
if email and domain:
message = f"Can't send email to '{email}' on domain '{domain}'. No email exists for the requestor."
elif email and portfolio:
message = f"Can't send email to '{email}' for portfolio '{portfolio}'. No email exists for the requestor."
super().__init__(message)
class OutsideOrgMemberError(ValueError):