diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 6bc15de5d..44c93892c 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -520,6 +520,10 @@ 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") + DomainInformation.create_from_da(self) + # create the permission for the user UserDomainRole = apps.get_model("registrar.UserDomainRole") UserDomainRole.objects.get_or_create( @@ -581,9 +585,10 @@ class DomainApplication(TimeStampedModel): def to_dict(self): """This is to process to_dict for Domain Information, making it friendly to "copy" it - + More information can be found at this- (This used #5) - https://stackoverflow.com/questions/21925671/convert-django-model-object-to-dict-with-all-of-the-fields-intact/29088221#29088221""" + https://stackoverflow.com/questions/21925671/convert-django-model-object-to-dict-with-all-of-the-fields-intact/29088221#29088221 + """ # noqa 590 opts = self._meta data = {} for field in chain(opts.concrete_fields, opts.private_fields): diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index 784920ec5..c8ae17058 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -4,6 +4,7 @@ from django.db.utils import IntegrityError from registrar.models import ( Contact, DomainApplication, + DomainInformation, User, Website, Domain, @@ -63,6 +64,31 @@ class TestDomainApplication(TestCase): application.other_contacts.add(contact) application.save() + def test_domain_info(self): + """Can create domain info with all fields.""" + user, _ = User.objects.get_or_create() + contact = Contact.objects.create() + domain, _ = Domain.objects.get_or_create(name="igorville.gov") + information = DomainInformation.objects.create( + creator=user, + organization_type=DomainInformation.OrganizationChoices.FEDERAL, + federal_type=DomainInformation.BranchChoices.EXECUTIVE, + is_election_board=False, + organization_name="Test", + address_line1="100 Main St.", + address_line2="APT 1A", + state_territory="CA", + zipcode="12345-6789", + authorizing_official=contact, + submitter=contact, + purpose="Igorville rules!", + anything_else="All of Igorville loves the dotgov program.", + is_policy_acknowledged=True, + domain=domain, + ) + information.other_contacts.add(contact) + information.save() + def test_status_fsm_submit_fail(self): user, _ = User.objects.get_or_create() application = DomainApplication.objects.create(creator=user)