mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-11 06:54:48 +02:00
Lint
This commit is contained in:
parent
8982d8d293
commit
4498ae7847
2 changed files with 10 additions and 19 deletions
|
@ -516,18 +516,6 @@ class DomainApplication(TimeStampedModel):
|
|||
application into an admin on that domain.
|
||||
"""
|
||||
|
||||
# create the domain if it doesn't exist
|
||||
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()
|
||||
# remove PK from domainapplication as it use different PK
|
||||
# for domain/domaininformation
|
||||
|
||||
domain_info = DomainInformation.create_from_da(self)
|
||||
|
||||
# create the permission for the user
|
||||
UserDomainRole = apps.get_model("registrar.UserDomainRole")
|
||||
UserDomainRole.objects.get_or_create(
|
||||
|
@ -587,7 +575,8 @@ 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):
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
from __future__ import annotations
|
||||
from typing import Union
|
||||
from .domain_application import DomainApplication
|
||||
from .utility.time_stamped_model import TimeStampedModel
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.db import models
|
||||
|
||||
|
||||
|
@ -14,7 +12,8 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
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
|
||||
|
||||
|
@ -160,7 +159,8 @@ class DomainInformation(TimeStampedModel):
|
|||
on_delete=models.PROTECT,
|
||||
blank=True,
|
||||
null=True,
|
||||
related_name="domain_info", # Access this information via Domain as "domain.info"
|
||||
# Access this information via Domain as "domain.info"
|
||||
related_name="domain_info",
|
||||
help_text="Domain to which this information belongs",
|
||||
)
|
||||
alternative_domains = models.ManyToManyField(
|
||||
|
@ -230,7 +230,8 @@ class DomainInformation(TimeStampedModel):
|
|||
da_dict = domain_application.to_dict()
|
||||
# remove the id so one can be assinged on creation
|
||||
da_id = da_dict.pop("id")
|
||||
# check if we have a record that corresponds with the domain application, if so short circuit the create
|
||||
# check if we have a record that corresponds with the domain
|
||||
# application, if so short circuit the create
|
||||
domain_info = cls.objects.filter(domain_application__id=da_id).first()
|
||||
if domain_info:
|
||||
return domain_info
|
||||
|
@ -243,7 +244,8 @@ class DomainInformation(TimeStampedModel):
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue