From 4498ae7847a1054d630b753ccba0404d181a12e5 Mon Sep 17 00:00:00 2001 From: Jon Roberts Date: Mon, 8 May 2023 15:41:20 -0400 Subject: [PATCH] Lint --- src/registrar/models/domain_application.py | 15 ++------------- src/registrar/models/domain_information.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index c73061216..67e0aeed7 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -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): diff --git a/src/registrar/models/domain_information.py b/src/registrar/models/domain_information.py index fb814af93..0d1864496 100644 --- a/src/registrar/models/domain_information.py +++ b/src/registrar/models/domain_information.py @@ -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