Add delete functionality for sec email

This commit is contained in:
zandercymatics 2023-10-06 13:27:16 -06:00
parent 8da6578b46
commit 3625fc0927
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -21,6 +21,7 @@ from registrar.models import (
User,
UserDomainRole,
)
from registrar.models.public_contact import PublicContact
from ..forms import (
ContactForm,
@ -297,7 +298,11 @@ class DomainSecurityEmailView(DomainPermissionView, FormMixin):
"""The form is valid, call setter in model."""
# Set the security email from the form
new_email = form.cleaned_data.get("security_email", "")
new_email: str = form.cleaned_data.get("security_email", "")
# If we pass nothing for the sec email, set to the default
if new_email is None or new_email.strip() == "":
new_email = PublicContact.get_default_security().email
domain = self.get_object()
contact = domain.security_contact