mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 21:44:08 +02:00
Add rule not to parse cases where the org name matches the portfolio name
This commit is contained in:
parent
822c8dde0f
commit
6d13f26ffb
3 changed files with 28 additions and 0 deletions
|
@ -926,6 +926,7 @@ These fields are: requested_suborganization, suborganization_city, suborganizati
|
|||
|
||||
This is done by pulling from organization_name, city, and state_territory.
|
||||
The script will only parse records with a portfolio but no suborganization attached to it.
|
||||
Additionally, it will not parse records wherein the organization name matches the portfolio org name.
|
||||
|
||||
### Running on sandboxes
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
|||
from django.core.management import BaseCommand
|
||||
from registrar.management.commands.utility.terminal_helper import PopulateScriptTemplate, TerminalColors, TerminalHelper
|
||||
from registrar.models import DomainRequest
|
||||
from django.db.models import F
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -16,6 +17,10 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
|||
fields_to_update = ["requested_suborganization", "suborganization_city", "suborganization_state_territory"]
|
||||
self.mass_update_records(DomainRequest, filter_conditions, fields_to_update)
|
||||
|
||||
def custom_filter(self, records):
|
||||
"""Exclude domain requests that have the same org name as the portfolio"""
|
||||
return records.exclude(organization_name=F("portfolio__organization_name"))
|
||||
|
||||
def update_record(self, record: DomainRequest):
|
||||
"""Adds data to requested_suborganization, suborganization_city, and suborganization_state_territory."""
|
||||
record.requested_suborganization = record.organization_name
|
||||
|
|
|
@ -1764,6 +1764,16 @@ class TestPopulateRequestedSuborg(MockEppLib):
|
|||
sub_organization=self.suborg,
|
||||
)
|
||||
|
||||
# Create a request where org name matches portfolio name
|
||||
self.matching_name_request = completed_domain_request(
|
||||
name="matching.gov",
|
||||
organization_name="Test Portfolio",
|
||||
city="Boston",
|
||||
state_territory="MA",
|
||||
portfolio=self.portfolio,
|
||||
user=self.user,
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
DomainRequest.objects.all().delete()
|
||||
|
@ -1804,3 +1814,15 @@ class TestPopulateRequestedSuborg(MockEppLib):
|
|||
self.assertIsNone(self.existing_suborg_request.requested_suborganization)
|
||||
self.assertIsNone(self.existing_suborg_request.suborganization_city)
|
||||
self.assertIsNone(self.existing_suborg_request.suborganization_state_territory)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_populate_requested_suborg_matching_name(self):
|
||||
"""Tests that requests with matching org/portfolio names are skipped"""
|
||||
self.run_populate_requested_suborg()
|
||||
|
||||
self.matching_name_request.refresh_from_db()
|
||||
|
||||
# Verify the request wasn't modified since org name matches portfolio name
|
||||
self.assertIsNone(self.matching_name_request.requested_suborganization)
|
||||
self.assertIsNone(self.matching_name_request.suborganization_city)
|
||||
self.assertIsNone(self.matching_name_request.suborganization_state_territory)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue