', normalized_html_content)
+ # Assert that modal does not appear on subsequent submits
+ self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
+ # Assert that unique error message appears by testing the message in a specific div
+ html_content = user_profile_page.content.decode("utf-8")
+ # Normalize spaces and line breaks in the HTML content
+ normalized_html_content = " ".join(html_content.split())
+ # Expected string without extra spaces and line breaks
+ expected_string = "Before you can manage your domain, we need you to add contact information."
+ # Check for the presence of the
element with the specific text
+ self.assertIn(f'
{expected_string}
', normalized_html_content)
- # We're missing a phone number, so the page should tell us that
- self.assertContains(user_profile_page, "Enter your phone number.")
+ # We're missing a phone number, so the page should tell us that
+ self.assertContains(user_profile_page, "Enter your phone number.")
- # We need to assert that links to manage your domain are not present (in both body and footer)
- self.assertNotContains(user_profile_page, "Manage your domains")
- # Assert the tooltip on the logo, indicating that the logo is not clickable
- self.assertContains(
- user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."'
- )
- # Assert that modal does not appear on subsequent submits
- self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
+ # We need to assert that links to manage your domain are not present (in both body and footer)
+ self.assertNotContains(user_profile_page, "Manage your domains")
+ # Assert the tooltip on the logo, indicating that the logo is not clickable
+ self.assertContains(
+ user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."'
+ )
+ # Assert that modal does not appear on subsequent submits
+ self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
- # Add a phone number
- finish_setup_form = user_profile_page.form
- finish_setup_form["phone"] = "(201) 555-0123"
- finish_setup_form["title"] = "CEO"
- finish_setup_form["last_name"] = "example"
- save_page = self._submit_form_webtest(finish_setup_form, follow=True)
+ # Add a phone number
+ finish_setup_form = user_profile_page.form
+ finish_setup_form["phone"] = "(201) 555-0123"
+ finish_setup_form["title"] = "CEO"
+ finish_setup_form["last_name"] = "example"
+ save_page = self._submit_form_webtest(finish_setup_form, follow=True)
- self.assertEqual(save_page.status_code, 200)
- self.assertContains(save_page, "Your profile has been updated.")
+ self.assertEqual(save_page.status_code, 200)
+ self.assertContains(save_page, "Your profile has been updated.")
- # We need to assert that logo is not clickable and links to manage your domain are not present
- # NOTE: "anage" is not a typo. It is to accomodate the fact that the "m" is uppercase in one
- # instance and lowercase in the other.
- self.assertContains(save_page, "anage your domains", count=2)
- self.assertNotContains(
- save_page, "Before you can manage your domains, we need you to add contact information"
- )
- # Assert that modal does not appear on subsequent submits
- self.assertNotContains(save_page, "domain registrants must maintain accurate contact information")
+ # We need to assert that logo is not clickable and links to manage your domain are not present
+ # NOTE: "anage" is not a typo. It is to accomodate the fact that the "m" is uppercase in one
+ # instance and lowercase in the other.
+ self.assertContains(save_page, "anage your domains", count=2)
+ self.assertNotContains(save_page, "Before you can manage your domains, we need you to add contact information")
+ # Assert that modal does not appear on subsequent submits
+ self.assertNotContains(save_page, "domain registrants must maintain accurate contact information")
- # Try to navigate back to the home page.
- # This is the same as clicking the back button.
- completed_setup_page = self.app.get(reverse("home"))
- self.assertContains(completed_setup_page, "Manage your domain")
+ # Try to navigate back to the home page.
+ # This is the same as clicking the back button.
+ completed_setup_page = self.app.get(reverse("home"))
+ self.assertContains(completed_setup_page, "Manage your domain")
class UserProfileTests(TestWithUser, WebTest):
@@ -915,113 +895,59 @@ class UserProfileTests(TestWithUser, WebTest):
DomainInformation.objects.all().delete()
@less_console_noise_decorator
- def error_500_main_nav_with_profile_feature_turned_on(self):
- """test that Your profile is in main nav of 500 error page when profile_feature is on.
+ def error_500_main_nav(self):
+ """test that Your profile is in main nav of 500 error page.
Our treatment of 401 and 403 error page handling with that waffle feature is similar, so we
assume that the same test results hold true for 401 and 403."""
- with override_flag("profile_feature", active=True):
- with self.assertRaises(Exception):
- response = self.client.get(reverse("home"), follow=True)
- self.assertEqual(response.status_code, 500)
- self.assertContains(response, "Your profile")
+ with self.assertRaises(Exception):
+ response = self.client.get(reverse("home"), follow=True)
+ self.assertEqual(response.status_code, 500)
+ self.assertContains(response, "Your profile")
@less_console_noise_decorator
- def error_500_main_nav_with_profile_feature_turned_off(self):
- """test that Your profile is not in main nav of 500 error page when profile_feature is off.
-
- Our treatment of 401 and 403 error page handling with that waffle feature is similar, so we
- assume that the same test results hold true for 401 and 403."""
- with override_flag("profile_feature", active=False):
- with self.assertRaises(Exception):
- response = self.client.get(reverse("home"), follow=True)
- self.assertEqual(response.status_code, 500)
- self.assertNotContains(response, "Your profile")
-
- @less_console_noise_decorator
- def test_home_page_main_nav_with_profile_feature_on(self):
- """test that Your profile is in main nav of home page when profile_feature is on"""
- with override_flag("profile_feature", active=True):
- response = self.client.get("/", follow=True)
+ def test_home_page_main_nav(self):
+ """test that Your profile is in main nav of home page"""
+ response = self.client.get("/", follow=True)
self.assertContains(response, "Your profile")
@less_console_noise_decorator
- def test_home_page_main_nav_with_profile_feature_off(self):
- """test that Your profile is not in main nav of home page when profile_feature is off"""
- with override_flag("profile_feature", active=False):
- response = self.client.get("/", follow=True)
- self.assertNotContains(response, "Your profile")
-
- @less_console_noise_decorator
- def test_new_request_main_nav_with_profile_feature_on(self):
- """test that Your profile is in main nav of new request when profile_feature is on"""
- with override_flag("profile_feature", active=True):
- response = self.client.get("/request/", follow=True)
+ def test_new_request_main_nav(self):
+ """test that Your profile is in main nav of new request"""
+ response = self.client.get("/request/", follow=True)
self.assertContains(response, "Your profile")
@less_console_noise_decorator
- def test_new_request_main_nav_with_profile_feature_off(self):
- """test that Your profile is not in main nav of new request when profile_feature is off"""
- with override_flag("profile_feature", active=False):
- response = self.client.get("/request/", follow=True)
- self.assertNotContains(response, "Your profile")
-
- @less_console_noise_decorator
- def test_user_profile_main_nav_with_profile_feature_on(self):
- """test that Your profile is in main nav of user profile when profile_feature is on"""
- with override_flag("profile_feature", active=True):
- response = self.client.get("/user-profile", follow=True)
+ def test_user_profile_main_nav(self):
+ """test that Your profile is in main nav of user profile"""
+ response = self.client.get("/user-profile", follow=True)
self.assertContains(response, "Your profile")
- @less_console_noise_decorator
- def test_user_profile_returns_404_when_feature_off(self):
- """test that Your profile returns 404 when profile_feature is off"""
- with override_flag("profile_feature", active=False):
- response = self.client.get("/user-profile", follow=True)
- self.assertEqual(response.status_code, 404)
-
@less_console_noise_decorator
def test_user_profile_back_button_when_coming_from_domain_request(self):
- """tests user profile when profile_feature is on,
+ """tests user profile,
and when they are redirected from the domain request page"""
- with override_flag("profile_feature", active=True):
- response = self.client.get("/user-profile?redirect=domain-request:")
+ response = self.client.get("/user-profile?redirect=domain-request:")
self.assertContains(response, "Your profile")
self.assertContains(response, "Go back to your domain request")
self.assertNotContains(response, "Back to manage your domains")
@less_console_noise_decorator
- def test_domain_detail_profile_feature_on(self):
- """test that domain detail view when profile_feature is on"""
- with override_flag("profile_feature", active=True):
- response = self.client.get(reverse("domain", args=[self.domain.pk]))
+ def test_domain_detail_contains_your_profile(self):
+ """Tests that the domain detail view contains 'your profile' rather than 'your contact information'"""
+ response = self.client.get(reverse("domain", args=[self.domain.pk]))
self.assertContains(response, "Your profile")
self.assertNotContains(response, "Your contact information")
@less_console_noise_decorator
- def test_request_when_profile_feature_on(self):
- """test that Your profile is in request page when profile feature is on"""
-
- contact_user, _ = Contact.objects.get_or_create(
- first_name="Hank",
- last_name="McFakerson",
- )
- site = DraftDomain.objects.create(name="igorville.gov")
- domain_request = DomainRequest.objects.create(
- creator=self.user,
- requested_domain=site,
- status=DomainRequest.DomainRequestStatus.SUBMITTED,
- senior_official=contact_user,
- )
- with override_flag("profile_feature", active=True):
- response = self.client.get(f"/domain-request/{domain_request.id}", follow=True)
- self.assertContains(response, "Your profile")
- response = self.client.get(f"/domain-request/{domain_request.id}/withdraw", follow=True)
- self.assertContains(response, "Your profile")
+ def test_domain_your_contact_information(self):
+ """test that your contact information is not accessible"""
+ response = self.client.get(f"/domain/{self.domain.id}/your-contact-information", follow=True)
+ self.assertEqual(response.status_code, 404)
@less_console_noise_decorator
- def test_request_when_profile_feature_off(self):
- """test that Your profile is not in request page when profile feature is off"""
+ def test_profile_request_page(self):
+ """test that your profile is in request"""
contact_user, _ = Contact.objects.get_or_create(
first_name="Hank",
@@ -1034,31 +960,27 @@ class UserProfileTests(TestWithUser, WebTest):
status=DomainRequest.DomainRequestStatus.SUBMITTED,
senior_official=contact_user,
)
- with override_flag("profile_feature", active=False):
- response = self.client.get(f"/domain-request/{domain_request.id}", follow=True)
- self.assertNotContains(response, "Your profile")
- response = self.client.get(f"/domain-request/{domain_request.id}/withdraw", follow=True)
- self.assertNotContains(response, "Your profile")
- # cleanup
- domain_request.delete()
- site.delete()
+
+ response = self.client.get(f"/domain-request/{domain_request.id}", follow=True)
+ self.assertContains(response, "Your profile")
+ response = self.client.get(f"/domain-request/{domain_request.id}/withdraw", follow=True)
+ self.assertContains(response, "Your profile")
@less_console_noise_decorator
def test_user_profile_form_submission(self):
"""test user profile form submission"""
self.app.set_user(self.user.username)
- with override_flag("profile_feature", active=True):
- profile_page = self.app.get(reverse("user-profile"))
- session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
- self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
- profile_form = profile_page.form
- profile_form["title"] = "sample title"
- profile_form["phone"] = "(201) 555-1212"
- profile_page = profile_form.submit()
- self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
- profile_page = profile_page.follow()
- self.assertEqual(profile_page.status_code, 200)
- self.assertContains(profile_page, "Your profile has been updated")
+ profile_page = self.app.get(reverse("user-profile"))
+ session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
+ self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
+ profile_form = profile_page.form
+ profile_form["title"] = "sample title"
+ profile_form["phone"] = "(201) 555-1212"
+ profile_page = profile_form.submit()
+ self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
+ profile_page = profile_page.follow()
+ self.assertEqual(profile_page.status_code, 200)
+ self.assertContains(profile_page, "Your profile has been updated")
class PortfoliosTests(TestWithUser, WebTest):
diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py
index c57cbe483..8fb92df72 100644
--- a/src/registrar/tests/test_views_domain.py
+++ b/src/registrar/tests/test_views_domain.py
@@ -723,7 +723,7 @@ class TestDomainManagers(TestDomainOverview):
email_address = "mayor@igorville.gov"
invitation, _ = DomainInvitation.objects.get_or_create(domain=self.domain, email=email_address)
- other_user = User()
+ other_user = create_user()
other_user.save()
self.client.force_login(other_user)
mock_client = MagicMock()
@@ -737,6 +737,12 @@ class TestDomainManagers(TestDomainOverview):
def test_domain_invitation_flow(self):
"""Send an invitation to a new user, log in and load the dashboard."""
email_address = "mayor@igorville.gov"
+ username = "mayor"
+ first_name = "First"
+ last_name = "Last"
+ title = "title"
+ phone = "8080102431"
+ title = "title"
User.objects.filter(email=email_address).delete()
add_page = self.app.get(reverse("domain-users-add", kwargs={"pk": self.domain.id}))
@@ -752,7 +758,9 @@ class TestDomainManagers(TestDomainOverview):
add_page.form.submit()
# user was invited, create them
- new_user = User.objects.create(username=email_address, email=email_address)
+ new_user = User.objects.create(
+ username=username, email=email_address, first_name=first_name, last_name=last_name, title=title, phone=phone
+ )
# log them in to `self.app`
self.app.set_user(new_user.username)
# and manually call the on each login callback
@@ -1298,7 +1306,9 @@ class TestDomainOrganization(TestDomainOverview):
"""Can load domain's org name and mailing address page."""
page = self.client.get(reverse("domain-org-name-address", kwargs={"pk": self.domain.id}))
# once on the sidebar, once in the page title, once as H1
- self.assertContains(page, "Organization name and mailing address", count=4)
+ self.assertContains(page, "/org-name-address")
+ self.assertContains(page, "Organization name and mailing address")
+ self.assertContains(page, "Organization")
@less_console_noise_decorator
def test_domain_org_name_address_content(self):
@@ -1607,7 +1617,7 @@ class TestDomainSuborganization(TestDomainOverview):
# Test for the title change
self.assertContains(page, "Suborganization")
- self.assertNotContains(page, "Organization name")
+ self.assertNotContains(page, "Organization")
# Test for the good value
self.assertContains(page, "Ice Cream")
diff --git a/src/registrar/tests/test_views_portfolio.py b/src/registrar/tests/test_views_portfolio.py
index b8392a370..abb8f8178 100644
--- a/src/registrar/tests/test_views_portfolio.py
+++ b/src/registrar/tests/test_views_portfolio.py
@@ -200,7 +200,7 @@ class TestPortfolio(WebTest):
# Assert the response is a 200
self.assertEqual(response.status_code, 200)
# The label for Federal agency will always be a h4
- self.assertContains(response, '
Federal agency
')
+ self.assertContains(response, '
Organization name
')
# The read only label for city will be a h4
self.assertContains(response, '
City
')
self.assertNotContains(response, 'for="id_city"')
@@ -225,10 +225,10 @@ class TestPortfolio(WebTest):
# Assert the response is a 200
self.assertEqual(response.status_code, 200)
# The label for Federal agency will always be a h4
- self.assertContains(response, '
Federal agency
')
+ self.assertContains(response, '
Organization name
')
# The read only label for city will be a h4
self.assertNotContains(response, '
City
')
- self.assertNotContains(response, '
Los Angeles
>')
+ self.assertNotContains(response, '
Los Angeles
')
self.assertContains(response, 'for="id_city"')
@less_console_noise_decorator
@@ -342,9 +342,7 @@ class TestPortfolio(WebTest):
user=self.user, portfolio=self.portfolio, additional_permissions=portfolio_additional_permissions
)
page = self.app.get(reverse("organization"))
- self.assertContains(
- page, "The name of your federal agency will be publicly listed as the domain registrant."
- )
+ self.assertContains(page, "The name of your organization will be publicly listed as the domain registrant.")
@less_console_noise_decorator
def test_domain_org_name_address_content(self):
diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py
index 6dde70f1a..2cb3a381c 100644
--- a/src/registrar/tests/test_views_request.py
+++ b/src/registrar/tests/test_views_request.py
@@ -1,6 +1,7 @@
from unittest import skip
-from unittest.mock import Mock
-
+from unittest.mock import Mock, patch
+from datetime import datetime
+from django.utils import timezone
from django.conf import settings
from django.urls import reverse
from api.tests.common import less_console_noise_decorator
@@ -56,6 +57,46 @@ class DomainRequestTests(TestWithUser, WebTest):
intro_page = self.app.get(reverse("domain-request:"))
self.assertContains(intro_page, "You’re about to start your .gov domain request")
+ @less_console_noise_decorator
+ def test_template_status_display(self):
+ """Tests the display of status-related information in the template."""
+ domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.SUBMITTED, user=self.user)
+ domain_request.last_submitted_date = datetime.now()
+ domain_request.save()
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+ self.assertContains(response, "Submitted on:")
+ self.assertContains(response, domain_request.last_submitted_date.strftime("%B %-d, %Y"))
+
+ @patch.object(DomainRequest, "get_first_status_set_date")
+ def test_get_first_status_started_date(self, mock_get_first_status_set_date):
+ """Tests retrieval of the first date the status was set to 'started'."""
+
+ # Set the mock to return a fixed date
+ fixed_date = timezone.datetime(2023, 1, 1).date()
+ mock_get_first_status_set_date.return_value = fixed_date
+
+ domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user)
+ domain_request.last_status_update = None
+ domain_request.save()
+
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+ # Ensure that the date is still set to None
+ self.assertIsNone(domain_request.last_status_update)
+ print(response)
+ # We should still grab a date for this field in this event - but it should come from the audit log instead
+ self.assertContains(response, "Started on:")
+ self.assertContains(response, fixed_date.strftime("%B %-d, %Y"))
+
+ # If a status date is set, we display that instead
+ domain_request.last_status_update = datetime.now()
+ domain_request.save()
+
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+
+ # We should still grab a date for this field in this event - but it should come from the audit log instead
+ self.assertContains(response, "Started on:")
+ self.assertContains(response, domain_request.last_status_update.strftime("%B %-d, %Y"))
+
@less_console_noise_decorator
def test_domain_request_form_intro_is_skipped_when_edit_access(self):
"""Tests that user is NOT presented with intro acknowledgement page when accessed through 'edit'"""
@@ -2206,7 +2247,6 @@ class DomainRequestTests(TestWithUser, WebTest):
senior_official = domain_request.senior_official
self.assertEquals("Testy2", senior_official.first_name)
- @override_flag("profile_feature", active=True)
@less_console_noise_decorator
def test_edit_creator_in_place(self):
"""When you:
diff --git a/src/registrar/tests/test_views_requests_json.py b/src/registrar/tests/test_views_requests_json.py
index cef608567..c6eb8a1dc 100644
--- a/src/registrar/tests/test_views_requests_json.py
+++ b/src/registrar/tests/test_views_requests_json.py
@@ -458,3 +458,81 @@ class GetRequestsJsonTest(TestWithUser, WebTest):
# Ensure no approved requests are included
for domain_request in data["domain_requests"]:
self.assertNotEqual(domain_request["status"], DomainRequest.DomainRequestStatus.APPROVED)
+
+ def test_search(self):
+ """Tests our search functionality. We expect that search filters on creator only when we are in a portfolio"""
+ # Test search for domain name
+ response = self.app.get(reverse("get_domain_requests_json"), {"search_term": "lamb"})
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertEqual(len(data["domain_requests"]), 1)
+
+ requested_domain = data["domain_requests"][0]["requested_domain"]
+ self.assertEqual(requested_domain, "lamb-chops.gov")
+
+ # Test search for 'New domain request'
+ response = self.app.get(reverse("get_domain_requests_json"), {"search_term": "new domain"})
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertTrue(any(req["requested_domain"] is None for req in data["domain_requests"]))
+
+ # Test search with portfolio (including creator search)
+ self.client.force_login(self.user)
+ with override_flag("organization_feature", active=True), override_flag("organization_requests", active=True):
+ user_perm, _ = UserPortfolioPermission.objects.get_or_create(
+ user=self.user,
+ portfolio=self.portfolio,
+ roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN],
+ )
+ response = self.app.get(
+ reverse("get_domain_requests_json"), {"search_term": "info", "portfolio": self.portfolio.id}
+ )
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertTrue(any(req["creator"].startswith("info") for req in data["domain_requests"]))
+
+ # Test search without portfolio (should not search on creator)
+ with override_flag("organization_feature", active=False), override_flag("organization_requests", active=False):
+ user_perm.delete()
+ response = self.app.get(reverse("get_domain_requests_json"), {"search_term": "info"})
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertEqual(len(data["domain_requests"]), 0)
+
+ @override_flag("organization_feature", active=True)
+ @override_flag("organization_requests", active=True)
+ def test_status_filter(self):
+ """Test that status filtering works properly"""
+ # Test a single status
+ response = self.app.get(reverse("get_domain_requests_json"), {"status": "started"})
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertTrue(all(req["status"] == "Started" for req in data["domain_requests"]))
+
+ # Test an invalid status
+ response = self.app.get(reverse("get_domain_requests_json"), {"status": "approved"})
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertEqual(len(data["domain_requests"]), 0)
+
+ @override_flag("organization_feature", active=True)
+ @override_flag("organization_requests", active=True)
+ def test_combined_filtering_and_sorting(self):
+ """Test that combining filters and sorting works properly"""
+ user_perm, _ = UserPortfolioPermission.objects.get_or_create(
+ user=self.user,
+ portfolio=self.portfolio,
+ roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN],
+ )
+ self.client.force_login(self.user)
+ response = self.app.get(
+ reverse("get_domain_requests_json"),
+ {"search_term": "beef", "status": "started", "portfolio": self.portfolio.id},
+ )
+ self.assertEqual(response.status_code, 200)
+ data = response.json
+ self.assertTrue(all("beef" in req["requested_domain"] for req in data["domain_requests"]))
+ self.assertTrue(all(req["status"] == "Started" for req in data["domain_requests"]))
+ created_at_dates = [req["created_at"] for req in data["domain_requests"]]
+ self.assertEqual(created_at_dates, sorted(created_at_dates, reverse=True))
+ user_perm.delete()
diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py
index 174f01ecc..db0572bb3 100644
--- a/src/registrar/views/domain.py
+++ b/src/registrar/views/domain.py
@@ -204,7 +204,7 @@ class DomainView(DomainBaseView):
class DomainOrgNameAddressView(DomainFormBaseView):
- """Organization name and mailing address view"""
+ """Organization view"""
model = Domain
template_name = "domain_org_name_address.html"
diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py
index 5fed89215..92e1b939e 100644
--- a/src/registrar/views/domain_request.py
+++ b/src/registrar/views/domain_request.py
@@ -82,7 +82,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
Step.TRIBAL_GOVERNMENT: _("Tribal government"),
Step.ORGANIZATION_FEDERAL: _("Federal government branch"),
Step.ORGANIZATION_ELECTION: _("Election office"),
- Step.ORGANIZATION_CONTACT: _("Organization name and mailing address"),
+ Step.ORGANIZATION_CONTACT: _("Organization"),
Step.ABOUT_YOUR_ORGANIZATION: _("About your organization"),
Step.SENIOR_OFFICIAL: _("Senior official"),
Step.CURRENT_SITES: _("Current websites"),
diff --git a/src/registrar/views/domain_requests_json.py b/src/registrar/views/domain_requests_json.py
index bc880cdaf..abaf029f2 100644
--- a/src/registrar/views/domain_requests_json.py
+++ b/src/registrar/views/domain_requests_json.py
@@ -20,6 +20,7 @@ def get_domain_requests_json(request):
unfiltered_total = objects.count()
objects = apply_search(objects, request)
+ objects = apply_status_filter(objects, request)
objects = apply_sorting(objects, request)
paginator = Paginator(objects, 10)
@@ -63,6 +64,7 @@ def get_domain_request_ids_from_request(request):
def apply_search(queryset, request):
search_term = request.GET.get("search_term")
+ is_portfolio = request.GET.get("portfolio")
if search_term:
search_term_lower = search_term.lower()
@@ -75,11 +77,34 @@ def apply_search(queryset, request):
queryset = queryset.filter(
Q(requested_domain__name__icontains=search_term) | Q(requested_domain__isnull=True)
)
+ elif is_portfolio:
+ queryset = queryset.filter(
+ Q(requested_domain__name__icontains=search_term)
+ | Q(creator__first_name__icontains=search_term)
+ | Q(creator__last_name__icontains=search_term)
+ | Q(creator__email__icontains=search_term)
+ )
+ # For non org users
else:
queryset = queryset.filter(Q(requested_domain__name__icontains=search_term))
return queryset
+def apply_status_filter(queryset, request):
+ status_param = request.GET.get("status")
+ if status_param:
+ status_list = status_param.split(",")
+ statuses = [status for status in status_list if status in DomainRequest.DomainRequestStatus.values]
+ # Construct Q objects for statuses that can be queried through ORM
+ status_query = Q()
+ if statuses:
+ status_query |= Q(status__in=statuses)
+ # Apply the combined query
+ queryset = queryset.filter(status_query)
+
+ return queryset
+
+
def apply_sorting(queryset, request):
sort_by = request.GET.get("sort_by", "id") # Default to 'id'
order = request.GET.get("order", "asc") # Default to 'asc'
diff --git a/src/registrar/views/user_profile.py b/src/registrar/views/user_profile.py
index 1dc61e23f..4d3b44366 100644
--- a/src/registrar/views/user_profile.py
+++ b/src/registrar/views/user_profile.py
@@ -11,7 +11,6 @@ from django.urls import NoReverseMatch, reverse
from registrar.models.user import User
from registrar.models.utility.generic_helper import replace_url_queryparams
from registrar.views.utility.permission_views import UserProfilePermissionView
-from waffle.decorators import waffle_flag
logger = logging.getLogger(__name__)
@@ -46,7 +45,6 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
return self.render_to_response(context)
- @waffle_flag("profile_feature") # type: ignore
def dispatch(self, request, *args, **kwargs): # type: ignore
return super().dispatch(request, *args, **kwargs)