This commit is contained in:
Jon Roberts 2023-05-08 15:30:49 -04:00
parent 381d8a6593
commit 8982d8d293
No known key found for this signature in database
GPG key ID: EED093582198B041
2 changed files with 15 additions and 18 deletions

View file

@ -13,6 +13,7 @@ from itertools import chain
logger = logging.getLogger(__name__)
class DomainApplication(TimeStampedModel):
"""A registrant's application for a new domain."""
@ -519,8 +520,6 @@ class DomainApplication(TimeStampedModel):
Domain = apps.get_model("registrar.Domain")
created_domain, _ = Domain.objects.get_or_create(name=self.requested_domain)
# copy the information from domainapplication into domaininformation
DomainInformation = apps.get_model("registrar.DomainInformation")
domain_info = self.to_dict()
@ -588,7 +587,7 @@ class DomainApplication(TimeStampedModel):
return False
def to_dict(instance):
"""This is to process to_dict for Domain Information, making it friendly to "copy" it """
"""This is to process to_dict for Domain Information, making it friendly to "copy" it"""
opts = instance._meta
data = {}
for field in chain(opts.concrete_fields, opts.private_fields):
@ -606,4 +605,3 @@ class DomainApplication(TimeStampedModel):
for field in opts.many_to_many:
data[field.name] = field.value_from_object(instance)
return data

View file

@ -11,17 +11,18 @@ from django.db import models
logger = logging.getLogger(__name__)
class DomainInformation(TimeStampedModel):
"""A registrant's domain information for that domain, exported from DomainApplication."""
StateTerritoryChoices=DomainApplication.StateTerritoryChoices
StateTerritoryChoices = DomainApplication.StateTerritoryChoices
OrganizationChoices=DomainApplication.OrganizationChoices
OrganizationChoices = DomainApplication.OrganizationChoices
BranchChoices=DomainApplication.BranchChoices
BranchChoices = DomainApplication.BranchChoices
AGENCY_CHOICES=DomainApplication.AGENCY_CHOICES
AGENCY_CHOICES = DomainApplication.AGENCY_CHOICES
# This is the application user who created this application. The contact
# information that they gave is in the `submitter` field
@ -45,7 +46,7 @@ class DomainInformation(TimeStampedModel):
null=True,
related_name="domainapplication_info",
help_text="Associated domain application",
unique=True
unique=True,
)
# ##### data fields from the initial form #####
@ -159,8 +160,8 @@ class DomainInformation(TimeStampedModel):
on_delete=models.PROTECT,
blank=True,
null=True,
related_name="domain_info", #Access this information via Domain as "domain.info"
help_text="Domain to which this information belongs"
related_name="domain_info", # Access this information via Domain as "domain.info"
help_text="Domain to which this information belongs",
)
alternative_domains = models.ManyToManyField(
"registrar.Website",
@ -239,19 +240,17 @@ class DomainInformation(TimeStampedModel):
# use the requested_domain to create information for this domain
da_dict["domain"] = da_dict.pop("requested_domain")
other_contacts = da_dict.pop("other_contacts")
alternative_domains = da_dict.pop("alternative_domains") #just in case
alternative_domains = da_dict.pop("alternative_domains") # just in case
domain_info = cls(**da_dict)
domain_info.domain_application = domain_application
#Save so the object now have PK (needed to process the manytomany below before first)
# Save so the object now have PK (needed to process the manytomany below before first)
domain_info.save()
#Process the remaining "many to many" stuff
# Process the remaining "many to many" stuff
domain_info.other_contacts.add(*other_contacts)
domain_info.alternative_domains.add(*alternative_domains)
domain_info.save()
return domain_info
class Meta:
verbose_name_plural = "Domain Information"