mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 18:25:58 +02:00
Fix bug with the DELETED state
This commit is contained in:
parent
7f34a389f4
commit
acd804b548
1 changed files with 43 additions and 2 deletions
|
@ -880,8 +880,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
|
||||
return self._handle_registrant_contact(desired_contact)
|
||||
|
||||
_registry_id: str
|
||||
if contact_type in contacts:
|
||||
_registry_id: str = ""
|
||||
if contacts is not None and contact_type in contacts:
|
||||
_registry_id = contacts.get(contact_type)
|
||||
|
||||
desired = PublicContact.objects.filter(
|
||||
|
@ -1293,6 +1293,47 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
except RegistryError as e:
|
||||
logger.error(e)
|
||||
|
||||
except TransitionNotAllowed:
|
||||
# Fixes a bug with _fetch_cache trying to create
|
||||
# a deleted domain, as cache gets cleared on delete.
|
||||
# Instead, serve what we have locally.
|
||||
if self.state == self.State.DELETED:
|
||||
logger.warning("Attempted to create a deleted domain")
|
||||
data = self._cache
|
||||
choices = PublicContact.ContactTypeChoices
|
||||
contacts_dict = {
|
||||
choices.ADMINISTRATIVE: None,
|
||||
choices.SECURITY: None,
|
||||
choices.TECHNICAL: None,
|
||||
}
|
||||
registrant_id = ...
|
||||
existing_contacts = PublicContact.objects.filter(
|
||||
domain=self
|
||||
)
|
||||
if existing_contacts.count() > 0:
|
||||
for choice in contacts_dict:
|
||||
contacts_dict[choice] = existing_contacts.get(contact_type=choice).registry_id
|
||||
# Edge case for registrant
|
||||
registrant = PublicContact.ContactTypeChoices.REGISTRANT
|
||||
registrant_id = existing_contacts.get(contact_type=registrant).registry_id
|
||||
|
||||
cache = {
|
||||
"auth_info": getattr(data, "auth_info", ...),
|
||||
"contacts": getattr(data, "contacts", contacts_dict),
|
||||
"cr_date": getattr(data, "cr_date", ...),
|
||||
"ex_date": getattr(data, "ex_date", ...),
|
||||
"hosts": getattr(data, "hosts", ...),
|
||||
"name": getattr(data, "name", self.name),
|
||||
"registrant": getattr(data, "name", registrant_id),
|
||||
"statuses": getattr(data, "statuses", ...),
|
||||
"tr_date": getattr(data, "tr_date", ...),
|
||||
"up_date": getattr(data, "up_date", ...),
|
||||
}
|
||||
cleaned = {k: v for k, v in cache.items() if v is not ...}
|
||||
|
||||
self._cache = cleaned
|
||||
|
||||
|
||||
def _get_or_create_public_contact(self, public_contact: PublicContact):
|
||||
"""Tries to find a PublicContact object in our DB.
|
||||
If it can't, it'll create it. Returns PublicContact"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue