mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-20 09:46:06 +02:00
Add enum for email defaults
This commit is contained in:
parent
abb4bd8a3f
commit
023e150597
5 changed files with 27 additions and 7 deletions
|
@ -12,6 +12,7 @@ from django.utils import timezone
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from registrar.models.host import Host
|
from registrar.models.host import Host
|
||||||
from registrar.models.host_ip import HostIP
|
from registrar.models.host_ip import HostIP
|
||||||
|
from registrar.utility.enums import DefaultEmail
|
||||||
|
|
||||||
from registrar.utility.errors import (
|
from registrar.utility.errors import (
|
||||||
ActionNotAllowed,
|
ActionNotAllowed,
|
||||||
|
@ -1400,7 +1401,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
is_security = contact.contact_type == contact.ContactTypeChoices.SECURITY
|
is_security = contact.contact_type == contact.ContactTypeChoices.SECURITY
|
||||||
DF = epp.DiscloseField
|
DF = epp.DiscloseField
|
||||||
fields = {DF.EMAIL}
|
fields = {DF.EMAIL}
|
||||||
disclose = is_security and contact.email != PublicContact.get_default_security().email
|
|
||||||
|
hidden_security_emails = [DefaultEmail.PUBLIC_CONTACT_DEFAULT, DefaultEmail.LEGACY_DEFAULT]
|
||||||
|
disclose = is_security and contact.email not in hidden_security_emails
|
||||||
# Delete after testing on other devices
|
# Delete after testing on other devices
|
||||||
logger.info("Updated domain contact %s to disclose: %s", contact.email, disclose)
|
logger.info("Updated domain contact %s to disclose: %s", contact.email, disclose)
|
||||||
# Will only disclose DF.EMAIL if its not the default
|
# Will only disclose DF.EMAIL if its not the default
|
||||||
|
|
|
@ -4,6 +4,8 @@ from string import ascii_uppercase, ascii_lowercase, digits
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
from registrar.utility.enums import DefaultEmail
|
||||||
|
|
||||||
from .utility.time_stamped_model import TimeStampedModel
|
from .utility.time_stamped_model import TimeStampedModel
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ class PublicContact(TimeStampedModel):
|
||||||
sp="VA",
|
sp="VA",
|
||||||
pc="20598-0645",
|
pc="20598-0645",
|
||||||
cc="US",
|
cc="US",
|
||||||
email="dotgov@cisa.dhs.gov",
|
email=DefaultEmail.PUBLIC_CONTACT_DEFAULT,
|
||||||
voice="+1.8882820870",
|
voice="+1.8882820870",
|
||||||
pw="thisisnotapassword",
|
pw="thisisnotapassword",
|
||||||
)
|
)
|
||||||
|
@ -104,7 +106,7 @@ class PublicContact(TimeStampedModel):
|
||||||
sp="VA",
|
sp="VA",
|
||||||
pc="22201",
|
pc="22201",
|
||||||
cc="US",
|
cc="US",
|
||||||
email="dotgov@cisa.dhs.gov",
|
email=DefaultEmail.PUBLIC_CONTACT_DEFAULT,
|
||||||
voice="+1.8882820870",
|
voice="+1.8882820870",
|
||||||
pw="thisisnotapassword",
|
pw="thisisnotapassword",
|
||||||
)
|
)
|
||||||
|
@ -121,7 +123,7 @@ class PublicContact(TimeStampedModel):
|
||||||
sp="VA",
|
sp="VA",
|
||||||
pc="22201",
|
pc="22201",
|
||||||
cc="US",
|
cc="US",
|
||||||
email="dotgov@cisa.dhs.gov",
|
email=DefaultEmail.PUBLIC_CONTACT_DEFAULT,
|
||||||
voice="+1.8882820870",
|
voice="+1.8882820870",
|
||||||
pw="thisisnotapassword",
|
pw="thisisnotapassword",
|
||||||
)
|
)
|
||||||
|
@ -138,7 +140,7 @@ class PublicContact(TimeStampedModel):
|
||||||
sp="VA",
|
sp="VA",
|
||||||
pc="22201",
|
pc="22201",
|
||||||
cc="US",
|
cc="US",
|
||||||
email="dotgov@cisa.dhs.gov",
|
email=DefaultEmail.PUBLIC_CONTACT_DEFAULT,
|
||||||
voice="+1.8882820870",
|
voice="+1.8882820870",
|
||||||
pw="thisisnotapassword",
|
pw="thisisnotapassword",
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,6 +8,8 @@ from django.db.models import Value
|
||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from registrar.utility.enums import DefaultEmail
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ def write_row(writer, columns, domain_info):
|
||||||
if security_contacts:
|
if security_contacts:
|
||||||
security_email = security_contacts[0].email
|
security_email = security_contacts[0].email
|
||||||
|
|
||||||
invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"}
|
invalid_emails = {DefaultEmail.LEGACY_DEFAULT, DefaultEmail.PUBLIC_CONTACT_DEFAULT}
|
||||||
# These are default emails that should not be displayed in the csv report
|
# These are default emails that should not be displayed in the csv report
|
||||||
if security_email is not None and security_email.lower() in invalid_emails:
|
if security_email is not None and security_email.lower() in invalid_emails:
|
||||||
security_email = "(blank)"
|
security_email = "(blank)"
|
||||||
|
|
|
@ -26,3 +26,15 @@ class LogCode(Enum):
|
||||||
INFO = 3
|
INFO = 3
|
||||||
DEBUG = 4
|
DEBUG = 4
|
||||||
DEFAULT = 5
|
DEFAULT = 5
|
||||||
|
|
||||||
|
|
||||||
|
class DefaultEmail(Enum):
|
||||||
|
"""Stores the string values of default emails
|
||||||
|
|
||||||
|
Overview of emails:
|
||||||
|
- PUBLIC_CONTACT_DEFAULT: "dotgov@cisa.dhs.gov"
|
||||||
|
- LEGACY_DEFAULT: "registrar@dotgov.gov"
|
||||||
|
"""
|
||||||
|
|
||||||
|
PUBLIC_CONTACT_DEFAULT = "dotgov@cisa.dhs.gov"
|
||||||
|
LEGACY_DEFAULT = "registrar@dotgov.gov"
|
||||||
|
|
|
@ -22,6 +22,7 @@ from registrar.models import (
|
||||||
UserDomainRole,
|
UserDomainRole,
|
||||||
)
|
)
|
||||||
from registrar.models.public_contact import PublicContact
|
from registrar.models.public_contact import PublicContact
|
||||||
|
from registrar.utility.enums import DefaultEmail
|
||||||
from registrar.utility.errors import (
|
from registrar.utility.errors import (
|
||||||
GenericError,
|
GenericError,
|
||||||
GenericErrorCodes,
|
GenericErrorCodes,
|
||||||
|
@ -569,7 +570,7 @@ class DomainSecurityEmailView(DomainFormBaseView):
|
||||||
initial = super().get_initial()
|
initial = super().get_initial()
|
||||||
security_contact = self.object.security_contact
|
security_contact = self.object.security_contact
|
||||||
|
|
||||||
invalid_emails = ["dotgov@cisa.dhs.gov", "registrar@dotgov.gov"]
|
invalid_emails = [DefaultEmail.PUBLIC_CONTACT_DEFAULT, DefaultEmail.LEGACY_DEFAULT]
|
||||||
if security_contact is None or security_contact.email in invalid_emails:
|
if security_contact is None or security_contact.email in invalid_emails:
|
||||||
initial["security_email"] = None
|
initial["security_email"] = None
|
||||||
return initial
|
return initial
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue