diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 67e0aeed7..14f542490 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -516,6 +516,10 @@ 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) + # create the permission for the user UserDomainRole = apps.get_model("registrar.UserDomainRole") UserDomainRole.objects.get_or_create( diff --git a/src/registrar/models/domain_information.py b/src/registrar/models/domain_information.py index 0d1864496..270592753 100644 --- a/src/registrar/models/domain_information.py +++ b/src/registrar/models/domain_information.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) class DomainInformation(TimeStampedModel): - """A registrant's domain information for that domain, exported from + """A registrant's domain information for that domain, exported from DomainApplication.""" StateTerritoryChoices = DomainApplication.StateTerritoryChoices @@ -160,7 +160,7 @@ class DomainInformation(TimeStampedModel): blank=True, null=True, # Access this information via Domain as "domain.info" - related_name="domain_info", + related_name="domain_info", help_text="Domain to which this information belongs", ) alternative_domains = models.ManyToManyField( @@ -230,7 +230,7 @@ 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 + # 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: @@ -244,7 +244,7 @@ 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 + # Save so the object now have PK # (needed to process the manytomany below before, first) domain_info.save()