mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-10 22:44:47 +02:00
Lint
This commit is contained in:
parent
381d8a6593
commit
8982d8d293
2 changed files with 15 additions and 18 deletions
|
@ -13,6 +13,7 @@ from itertools import chain
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DomainApplication(TimeStampedModel):
|
class DomainApplication(TimeStampedModel):
|
||||||
|
|
||||||
"""A registrant's application for a new domain."""
|
"""A registrant's application for a new domain."""
|
||||||
|
@ -519,8 +520,6 @@ class DomainApplication(TimeStampedModel):
|
||||||
Domain = apps.get_model("registrar.Domain")
|
Domain = apps.get_model("registrar.Domain")
|
||||||
created_domain, _ = Domain.objects.get_or_create(name=self.requested_domain)
|
created_domain, _ = Domain.objects.get_or_create(name=self.requested_domain)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# copy the information from domainapplication into domaininformation
|
# copy the information from domainapplication into domaininformation
|
||||||
DomainInformation = apps.get_model("registrar.DomainInformation")
|
DomainInformation = apps.get_model("registrar.DomainInformation")
|
||||||
domain_info = self.to_dict()
|
domain_info = self.to_dict()
|
||||||
|
@ -588,7 +587,7 @@ class DomainApplication(TimeStampedModel):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def to_dict(instance):
|
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
|
opts = instance._meta
|
||||||
data = {}
|
data = {}
|
||||||
for field in chain(opts.concrete_fields, opts.private_fields):
|
for field in chain(opts.concrete_fields, opts.private_fields):
|
||||||
|
@ -606,4 +605,3 @@ class DomainApplication(TimeStampedModel):
|
||||||
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(instance)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,18 @@ from django.db import models
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DomainInformation(TimeStampedModel):
|
class DomainInformation(TimeStampedModel):
|
||||||
|
|
||||||
"""A registrant's domain information for that domain, exported from DomainApplication."""
|
"""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
|
# This is the application user who created this application. The contact
|
||||||
# information that they gave is in the `submitter` field
|
# information that they gave is in the `submitter` field
|
||||||
|
@ -41,11 +42,11 @@ class DomainInformation(TimeStampedModel):
|
||||||
domain_application = models.OneToOneField(
|
domain_application = models.OneToOneField(
|
||||||
"registrar.DomainApplication",
|
"registrar.DomainApplication",
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
related_name="domainapplication_info",
|
related_name="domainapplication_info",
|
||||||
help_text="Associated domain application",
|
help_text="Associated domain application",
|
||||||
unique=True
|
unique=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ##### data fields from the initial form #####
|
# ##### data fields from the initial form #####
|
||||||
|
@ -157,10 +158,10 @@ class DomainInformation(TimeStampedModel):
|
||||||
domain = models.OneToOneField(
|
domain = models.OneToOneField(
|
||||||
"registrar.Domain",
|
"registrar.Domain",
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
related_name="domain_info", #Access this information via Domain as "domain.info"
|
related_name="domain_info", # Access this information via Domain as "domain.info"
|
||||||
help_text="Domain to which this information belongs"
|
help_text="Domain to which this information belongs",
|
||||||
)
|
)
|
||||||
alternative_domains = models.ManyToManyField(
|
alternative_domains = models.ManyToManyField(
|
||||||
"registrar.Website",
|
"registrar.Website",
|
||||||
|
@ -239,19 +240,17 @@ class DomainInformation(TimeStampedModel):
|
||||||
# use the requested_domain to create information for this domain
|
# use the requested_domain to create information for this domain
|
||||||
da_dict["domain"] = da_dict.pop("requested_domain")
|
da_dict["domain"] = da_dict.pop("requested_domain")
|
||||||
other_contacts = da_dict.pop("other_contacts")
|
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 = cls(**da_dict)
|
||||||
domain_info.domain_application = domain_application
|
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()
|
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.other_contacts.add(*other_contacts)
|
||||||
domain_info.alternative_domains.add(*alternative_domains)
|
domain_info.alternative_domains.add(*alternative_domains)
|
||||||
domain_info.save()
|
domain_info.save()
|
||||||
return domain_info
|
return domain_info
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "Domain Information"
|
verbose_name_plural = "Domain Information"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue