mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-23 21:09:22 +02:00
some minor modifications
This commit is contained in:
parent
d0ca1ccff1
commit
66bc63aad4
1 changed files with 43 additions and 39 deletions
|
@ -1608,7 +1608,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
cache = self._extract_data_from_response(data_response)
|
cache = self._extract_data_from_response(data_response)
|
||||||
cleaned = self._clean_cache(cache, data_response)
|
cleaned = self._clean_cache(cache, data_response)
|
||||||
self._update_hosts_and_contacts(cleaned, fetch_hosts, fetch_contacts)
|
self._update_hosts_and_contacts(cleaned, fetch_hosts, fetch_contacts)
|
||||||
self._update_hosts_and_ips_in_db(cleaned, fetch_hosts)
|
if fetch_hosts:
|
||||||
|
self._update_hosts_and_ips_in_db(cleaned)
|
||||||
self._update_dates(cleaned)
|
self._update_dates(cleaned)
|
||||||
|
|
||||||
self._cache = cleaned
|
self._cache = cleaned
|
||||||
|
@ -1655,7 +1656,11 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
return dnssec_data
|
return dnssec_data
|
||||||
|
|
||||||
def _update_hosts_and_contacts(self, cleaned, fetch_hosts, fetch_contacts):
|
def _update_hosts_and_contacts(self, cleaned, fetch_hosts, fetch_contacts):
|
||||||
"""Capture and cache old hosts and contacts from cache if they don't exist in cleaned"""
|
"""
|
||||||
|
Update hosts and contacts if fetch_hosts and/or fetch_contacts.
|
||||||
|
Additionally, capture and cache old hosts and contacts from cache if they
|
||||||
|
don't exist in cleaned
|
||||||
|
"""
|
||||||
old_cache_hosts = self._cache.get("hosts")
|
old_cache_hosts = self._cache.get("hosts")
|
||||||
old_cache_contacts = self._cache.get("contacts")
|
old_cache_contacts = self._cache.get("contacts")
|
||||||
|
|
||||||
|
@ -1670,16 +1675,15 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
if old_cache_contacts is not None:
|
if old_cache_contacts is not None:
|
||||||
cleaned["contacts"] = old_cache_contacts
|
cleaned["contacts"] = old_cache_contacts
|
||||||
|
|
||||||
def _update_hosts_and_ips_in_db(self, cleaned, fetch_hosts):
|
def _update_hosts_and_ips_in_db(self, cleaned):
|
||||||
"""Update hosts and host_ips in database if retrieved from registry.
|
"""Update hosts and host_ips in database if retrieved from registry.
|
||||||
|
Only called when fetch_hosts is True.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
self: the domain to be updated with hosts and ips from cleaned
|
self: the domain to be updated with hosts and ips from cleaned
|
||||||
cleaned: dict containing hosts. Hosts are provided as a list of dicts, e.g.
|
cleaned: dict containing hosts. Hosts are provided as a list of dicts, e.g.
|
||||||
[{"name": "ns1.example.com",}, {"name": "ns1.example.gov"}, "addrs": ["0.0.0.0"])]
|
[{"name": "ns1.example.com",}, {"name": "ns1.example.gov"}, "addrs": ["0.0.0.0"])]
|
||||||
fetch_hosts: boolean indicating whether or not fetch_hosts was called
|
|
||||||
"""
|
"""
|
||||||
if fetch_hosts:
|
|
||||||
cleaned_hosts = cleaned["hosts"]
|
cleaned_hosts = cleaned["hosts"]
|
||||||
# Get all existing hosts from the database for this domain
|
# Get all existing hosts from the database for this domain
|
||||||
existing_hosts_in_db = Host.objects.filter(domain=self)
|
existing_hosts_in_db = Host.objects.filter(domain=self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue