mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-01 10:13:55 +02:00
updated more PR feedback
This commit is contained in:
parent
08b2060f35
commit
7d38dce08c
2 changed files with 12 additions and 8 deletions
|
@ -578,24 +578,24 @@ class DomainApplication(TimeStampedModel):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def to_dict(instance):
|
def to_dict(self):
|
||||||
"""This is to process to_dict for Domain Information, making it friendly
|
"""This is to process to_dict for Domain Information, making it friendly
|
||||||
to "copy" it
|
to "copy" it
|
||||||
|
|
||||||
More information can be found at this- (This used #5)
|
More information can be found at this- (This used #5)
|
||||||
https://stackoverflow.com/questions/21925671/convert-django-model-object-to-dict-with-all-of-the-fields-intact/29088221#29088221"""
|
https://stackoverflow.com/questions/21925671/convert-django-model-object-to-dict-with-all-of-the-fields-intact/29088221#29088221"""
|
||||||
opts = instance._meta
|
opts = self._meta
|
||||||
data = {}
|
data = {}
|
||||||
for field in chain(opts.concrete_fields, opts.private_fields):
|
for field in chain(opts.concrete_fields, opts.private_fields):
|
||||||
if field.get_internal_type() in ("ForeignKey", "OneToOneField"):
|
if field.get_internal_type() in ("ForeignKey", "OneToOneField"):
|
||||||
# get the related instance of the FK value
|
# get the related instance of the FK value
|
||||||
fk_id = field.value_from_object(instance)
|
fk_id = field.value_from_object(self)
|
||||||
if fk_id:
|
if fk_id:
|
||||||
data[field.name] = field.related_model.objects.get(id=fk_id)
|
data[field.name] = field.related_model.objects.get(id=fk_id)
|
||||||
else:
|
else:
|
||||||
data[field.name] = None
|
data[field.name] = None
|
||||||
else:
|
else:
|
||||||
data[field.name] = field.value_from_object(instance)
|
data[field.name] = field.value_from_object(self)
|
||||||
for field in opts.many_to_many:
|
for field in opts.many_to_many:
|
||||||
data[field.name] = field.value_from_object(instance)
|
data[field.name] = field.value_from_object(self)
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -13,7 +13,11 @@ logger = logging.getLogger(__name__)
|
||||||
class DomainInformation(TimeStampedModel):
|
class DomainInformation(TimeStampedModel):
|
||||||
|
|
||||||
"""A registrant's domain information for that domain, exported from
|
"""A registrant's domain information for that domain, exported from
|
||||||
DomainApplication."""
|
DomainApplication. We use these field from DomainApplication with few exceptation
|
||||||
|
which are 'removed' via pop at the bottom of this file. Most of design for domain
|
||||||
|
management's user information are based on application, but we cannot change
|
||||||
|
the application once approved, so copying them that way we can make changes
|
||||||
|
after its approved. Most fields here are copied from Application."""
|
||||||
|
|
||||||
StateTerritoryChoices = DomainApplication.StateTerritoryChoices
|
StateTerritoryChoices = DomainApplication.StateTerritoryChoices
|
||||||
|
|
||||||
|
@ -152,7 +156,7 @@ class DomainInformation(TimeStampedModel):
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
# Access this information via Domain as "domain.info"
|
# Access this information via Domain as "domain.domain_info"
|
||||||
related_name="domain_info",
|
related_name="domain_info",
|
||||||
help_text="Domain to which this information belongs",
|
help_text="Domain to which this information belongs",
|
||||||
)
|
)
|
||||||
|
@ -208,7 +212,7 @@ class DomainInformation(TimeStampedModel):
|
||||||
if self.domain and self.domain.name:
|
if self.domain and self.domain.name:
|
||||||
return self.domain.name
|
return self.domain.name
|
||||||
else:
|
else:
|
||||||
return f"application created by {self.creator}"
|
return f"domain info set up and created by {self.creator}"
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue