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