mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-20 17:56:11 +02:00
Merge madness
This commit is contained in:
parent
ca189ff3d7
commit
60cf20fc3d
1 changed files with 48 additions and 64 deletions
|
@ -1026,46 +1026,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
raise ValueError("Not ready to become created, cannot transition yet")
|
raise ValueError("Not ready to become created, cannot transition yet")
|
||||||
logger.info("able to transition to ready state")
|
logger.info("able to transition to ready state")
|
||||||
|
|
||||||
def _fetch_contacts(self, contact_data):
|
|
||||||
"""Fetch contact info."""
|
|
||||||
contacts = []
|
|
||||||
for domainContact in contact_data:
|
|
||||||
req = commands.InfoContact(id=domainContact.contact)
|
|
||||||
data = registry.send(req, cleaned=True).res_data[0]
|
|
||||||
contact = {
|
|
||||||
"id": domainContact.contact,
|
|
||||||
"type": domainContact.type,
|
|
||||||
"auth_info": getattr(data, "auth_info", ...),
|
|
||||||
"cr_date": getattr(data, "cr_date", ...),
|
|
||||||
"disclose": getattr(data, "disclose", ...),
|
|
||||||
"email": getattr(data, "email", ...),
|
|
||||||
"fax": getattr(data, "fax", ...),
|
|
||||||
"postal_info": getattr(data, "postal_info", ...),
|
|
||||||
"statuses": getattr(data, "statuses", ...),
|
|
||||||
"tr_date": getattr(data, "tr_date", ...),
|
|
||||||
"up_date": getattr(data, "up_date", ...),
|
|
||||||
"voice": getattr(data, "voice", ...),
|
|
||||||
}
|
|
||||||
contacts.append({k: v for k, v in contact.items() if v is not ...})
|
|
||||||
return contacts
|
|
||||||
|
|
||||||
def _fetch_hosts(self, host_data):
|
|
||||||
"""Fetch host info."""
|
|
||||||
hosts = []
|
|
||||||
for name in host_data:
|
|
||||||
req = commands.InfoHost(name=name)
|
|
||||||
data = registry.send(req, cleaned=True).res_data[0]
|
|
||||||
host = {
|
|
||||||
"name": name,
|
|
||||||
"addrs": getattr(data, "addrs", ...),
|
|
||||||
"cr_date": getattr(data, "cr_date", ...),
|
|
||||||
"statuses": getattr(data, "statuses", ...),
|
|
||||||
"tr_date": getattr(data, "tr_date", ...),
|
|
||||||
"up_date": getattr(data, "up_date", ...),
|
|
||||||
}
|
|
||||||
hosts.append({k: v for k, v in host.items() if v is not ...})
|
|
||||||
return hosts
|
|
||||||
|
|
||||||
def _disclose_fields(self, contact: PublicContact):
|
def _disclose_fields(self, contact: PublicContact):
|
||||||
"""creates a disclose object that can be added to a contact Create using
|
"""creates a disclose object that can be added to a contact Create using
|
||||||
.disclose= <this function> on the command before sending.
|
.disclose= <this function> on the command before sending.
|
||||||
|
@ -1141,6 +1101,29 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
)
|
)
|
||||||
return err.code
|
return err.code
|
||||||
|
|
||||||
|
def _fetch_contacts(self, contact_data):
|
||||||
|
"""Fetch contact info."""
|
||||||
|
contacts = []
|
||||||
|
for domainContact in contact_data:
|
||||||
|
req = commands.InfoContact(id=domainContact.contact)
|
||||||
|
data = registry.send(req, cleaned=True).res_data[0]
|
||||||
|
contact = {
|
||||||
|
"id": domainContact.contact,
|
||||||
|
"type": domainContact.type,
|
||||||
|
"auth_info": getattr(data, "auth_info", ...),
|
||||||
|
"cr_date": getattr(data, "cr_date", ...),
|
||||||
|
"disclose": getattr(data, "disclose", ...),
|
||||||
|
"email": getattr(data, "email", ...),
|
||||||
|
"fax": getattr(data, "fax", ...),
|
||||||
|
"postal_info": getattr(data, "postal_info", ...),
|
||||||
|
"statuses": getattr(data, "statuses", ...),
|
||||||
|
"tr_date": getattr(data, "tr_date", ...),
|
||||||
|
"up_date": getattr(data, "up_date", ...),
|
||||||
|
"voice": getattr(data, "voice", ...),
|
||||||
|
}
|
||||||
|
contacts.append({k: v for k, v in contact.items() if v is not ...})
|
||||||
|
return contacts
|
||||||
|
|
||||||
def _get_or_create_contact(self, contact: PublicContact):
|
def _get_or_create_contact(self, contact: PublicContact):
|
||||||
"""Try to fetch info about a contact. Create it if it does not exist."""
|
"""Try to fetch info about a contact. Create it if it does not exist."""
|
||||||
try:
|
try:
|
||||||
|
@ -1167,6 +1150,23 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
def _fetch_hosts(self, host_data):
|
||||||
|
"""Fetch host info."""
|
||||||
|
hosts = []
|
||||||
|
for name in host_data:
|
||||||
|
req = commands.InfoHost(name=name)
|
||||||
|
data = registry.send(req, cleaned=True).res_data[0]
|
||||||
|
host = {
|
||||||
|
"name": name,
|
||||||
|
"addrs": getattr(data, "addrs", ...),
|
||||||
|
"cr_date": getattr(data, "cr_date", ...),
|
||||||
|
"statuses": getattr(data, "statuses", ...),
|
||||||
|
"tr_date": getattr(data, "tr_date", ...),
|
||||||
|
"up_date": getattr(data, "up_date", ...),
|
||||||
|
}
|
||||||
|
hosts.append({k: v for k, v in host.items() if v is not ...})
|
||||||
|
return hosts
|
||||||
|
|
||||||
def _update_or_create_host(self, host):
|
def _update_or_create_host(self, host):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@ -1242,33 +1242,17 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
# get nameserver info, if there are any
|
# get nameserver info, if there are any
|
||||||
if (
|
if (
|
||||||
# fetch_hosts and
|
fetch_hosts
|
||||||
"_hosts" in cleaned
|
and "_hosts" in cleaned
|
||||||
and isinstance(cleaned["_hosts"], list)
|
and isinstance(cleaned["_hosts"], list)
|
||||||
and len(cleaned["_hosts"])
|
and len(cleaned["_hosts"])
|
||||||
):
|
):
|
||||||
# TODO- add elif in cache set it to be the old cache value
|
cleaned["hosts"] = self._fetch_hosts(cleaned["_hosts"])
|
||||||
# no point in removing
|
# We're only getting hosts, so retain the old
|
||||||
cleaned["hosts"] = []
|
# contacts that existed in cache (if they existed)
|
||||||
for name in cleaned["_hosts"]:
|
# and pass them along.
|
||||||
# we do not use _get_or_create_* because we expect the object we
|
if old_cache_contacts is not None:
|
||||||
# just asked the registry for still exists --
|
cleaned["contacts"] = old_cache_contacts
|
||||||
# if not, that's a problem
|
|
||||||
req = commands.InfoHost(name=name)
|
|
||||||
data = registry.send(req, cleaned=True).res_data[0]
|
|
||||||
# extract properties from response
|
|
||||||
# (Ellipsis is used to mean "null")
|
|
||||||
host = {
|
|
||||||
"name": name,
|
|
||||||
"addrs": getattr(data, "addrs", ...),
|
|
||||||
"cr_date": getattr(data, "cr_date", ...),
|
|
||||||
"statuses": getattr(data, "statuses", ...),
|
|
||||||
"tr_date": getattr(data, "tr_date", ...),
|
|
||||||
"up_date": getattr(data, "up_date", ...),
|
|
||||||
}
|
|
||||||
cleaned["hosts"].append(
|
|
||||||
{k: v for k, v in host.items() if v is not ...}
|
|
||||||
)
|
|
||||||
# replace the prior cache with new data
|
# replace the prior cache with new data
|
||||||
self._cache = cleaned
|
self._cache = cleaned
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue