diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py
index 65a024395..9da32d118 100644
--- a/src/registrar/models/domain_request.py
+++ b/src/registrar/models/domain_request.py
@@ -1333,18 +1333,16 @@ class DomainRequest(TimeStampedModel):
return False
return True
+ """the following converted_ property methods get their respective field names from portfolio, if the domain request has a portfolio. if it does not, it will get the info from the model itself."""
+
@property
def converted_organization_name(self):
- """ "returns the organization field if the domain request is in a portfolio
- otherwise it returns the organization name from the domain request object itself"""
if self.portfolio:
return self.portfolio.organization_name
return self.organization_name
@property
def converted_generic_org_type(self):
- """ "returns the organization type if the domain request is in a portfolio
- otherwise it returns the organization type from the domain request object itself"""
if self.portfolio:
return self.portfolio.organization_type
return self.generic_org_type
diff --git a/src/registrar/tests/test_admin_request.py b/src/registrar/tests/test_admin_request.py
index 5de26ee4a..5c3f01787 100644
--- a/src/registrar/tests/test_admin_request.py
+++ b/src/registrar/tests/test_admin_request.py
@@ -576,6 +576,8 @@ class TestDomainRequestAdmin(MockEppLib):
response = self.client.get("/admin/registrar/domainrequest/?generic_org_type__exact=federal")
# There are 2 template references to Federal (4) and two in the results data
# of the request
+ self.assertContains(response, "Federal", count=48)
+ self.assertContains(response, "Converted federal", count=4)
# This may be a bit more robust
self.assertContains(response, '
federal | ', count=1)
# Now let's make sure the long description does not exist
diff --git a/src/registrar/tests/test_models_requests.py b/src/registrar/tests/test_models_requests.py
index 339841be0..53b9e802e 100644
--- a/src/registrar/tests/test_models_requests.py
+++ b/src/registrar/tests/test_models_requests.py
@@ -14,6 +14,7 @@ from registrar.models import (
DraftDomain,
FederalAgency,
AllowedEmail,
+ Portfolio,
)
import boto3_mocking
@@ -95,6 +96,7 @@ class TestDomainRequest(TestCase):
DomainRequest.objects.all().delete()
DraftDomain.objects.all().delete()
Domain.objects.all().delete()
+ Portfolio.objects.all().delete()
User.objects.all().delete()
self.mock_client.EMAILS_SENT.clear()
@@ -1045,3 +1047,25 @@ class TestDomainRequest(TestCase):
status=DomainRequest.DomainRequestStatus.STARTED, name="no-others.gov", has_other_contacts=False
)
self.assertEquals(domain_request.has_other_contacts(), False)
+
+ @less_console_noise_decorator
+ def test_converted_type(self):
+ """test that new property fields works as expected to pull domain req info such as fed agency, generic org type, and others from portfolio"""
+ fed_agency = FederalAgency.objects.filter(agency="Non-Federal Agency").first()
+ portfolio = Portfolio.objects.create(
+ organization_name="Test Portfolio",
+ creator=self.dummy_user_2,
+ federal_agency=fed_agency,
+ organization_type=DomainRequest.OrganizationChoices.FEDERAL,
+ )
+
+ domain_request = completed_domain_request(name="domainre1.gov", portfolio=portfolio)
+
+ self.assertEqual(portfolio.organization_type, domain_request.converted_generic_org_type)
+ self.assertEqual(portfolio.federal_agency, domain_request.converted_federal_agency)
+
+ domain_request2 = completed_domain_request(
+ name="domainreq2.gov", federal_agency=fed_agency, generic_org_type=DomainRequest.OrganizationChoices.TRIBAL
+ )
+ self.assertEqual(domain_request2.generic_org_type, domain_request2.converted_generic_org_type)
+ self.assertEqual(domain_request2.federal_agency, domain_request2.converted_federal_agency)