mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 08:52:16 +02:00
Update initial disclose script
This commit is contained in:
parent
7c87718e2d
commit
683a2f4629
2 changed files with 21 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
|||
""""Script description"""
|
||||
|
||||
import logging
|
||||
import copy
|
||||
|
||||
from django.core.management import BaseCommand
|
||||
from registrar.models import Domain
|
||||
|
@ -14,16 +15,20 @@ class Command(BaseCommand):
|
|||
def __init__(self):
|
||||
"""Sets global variables for code tidyness"""
|
||||
super().__init__()
|
||||
# this array is used to store domains with errors, which are not
|
||||
# successfully updated to disclose
|
||||
domains_with_errors: List[str] = []
|
||||
# domains and transition domains that must be disclosed to true
|
||||
self.domains_to_disclose: List[str] = []
|
||||
# domains with errors, which are not successfully updated to disclose
|
||||
self.domains_with_errors: List[str] = []
|
||||
# domains that are successfully disclosed
|
||||
self.disclosed_domain_contacts: List[str] = []
|
||||
|
||||
def handle(self, **options):
|
||||
"""
|
||||
Description for what update_security_email_disclose does
|
||||
"""
|
||||
logger.info("Updating security emails to public")
|
||||
|
||||
|
||||
# Initializes domains that need to be disclosed
|
||||
domains = Domain.objects.filter()
|
||||
|
||||
# Call security_contact on all domains to trigger saving contact information
|
||||
|
@ -31,23 +36,24 @@ class Command(BaseCommand):
|
|||
contact = domain.security_contact
|
||||
|
||||
domains_with_contact = Domain.objects.filter(
|
||||
security_contact_registry_id=True
|
||||
security_contact_registry_id__isnull=False
|
||||
)
|
||||
logger.info("Found %d domains with security contact.", len(domains_with_contact))
|
||||
|
||||
# Update EPP contact for domains with a security contact
|
||||
for domain in domains_with_contact:
|
||||
try:
|
||||
domain._update_epp_contact(contact=domain.security_contact_registry_id)
|
||||
logger.info("Updated EPP contact for domain %d to disclose: %d", domain, domain.security_contact.disclose)
|
||||
logger.info("Domain %s security contact: %s", domain, domain.security_contact)
|
||||
domain._update_epp_contact(contact=domain.security_contact)
|
||||
self.disclosed_domain_contacts.append(copy.deepcopy(domain.security_contact))
|
||||
except Exception as err:
|
||||
# error condition if domain not in database
|
||||
self.domains_with_errors.append(copy.deepcopy(domain.domain_name))
|
||||
logger.error(f"error retrieving domain {domain.domain_name}: {err}")
|
||||
self.domains_with_errors.append(copy.deepcopy(domain.domain_info))
|
||||
logger.error(f"error retrieving domain {domain.domain_info}: {err}")
|
||||
|
||||
domains_disclosed = Domain.objects.filter(
|
||||
security_contact_registry_id=True,
|
||||
)
|
||||
logger.info("Updated %d domains to disclosed.", len(domains_disclosed))
|
||||
# Update transition domains to disclose
|
||||
|
||||
# Inform user how many contacts were disclosed
|
||||
logger.info("Updated %d contacts to disclosed.", len(self.disclosed_domain_contacts))
|
||||
|
||||
|
||||
|
|
|
@ -1401,6 +1401,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
DF = epp.DiscloseField
|
||||
fields = {DF.EMAIL}
|
||||
disclose = is_security
|
||||
# Delete after testing
|
||||
logger.info("Updated domain contact to disclose: %s", disclose)
|
||||
# Will only disclose DF.EMAIL if its not the default
|
||||
return epp.Disclose(
|
||||
flag=disclose,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue