Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3234: Modify create_federal_portfolio script to add requested suborg fields - [AG] #3303

Merged
merged 42 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0118e1f
Add suborg data and clean duplicate script
zandercymatics Jan 6, 2025
d0183d4
cleanup
zandercymatics Jan 6, 2025
6086b95
Remove unrelated content
zandercymatics Jan 6, 2025
345ca03
Update create_federal_portfolio.py
zandercymatics Jan 6, 2025
5e6a798
Update create_federal_portfolio.py
zandercymatics Jan 6, 2025
9052d9e
Use dedicated script
zandercymatics Jan 6, 2025
188c99a
Unit tests and documentation
zandercymatics Jan 6, 2025
822c8dd
Update test_management_scripts.py
zandercymatics Jan 6, 2025
6d13f26
Add rule not to parse cases where the org name matches the portfolio …
zandercymatics Jan 6, 2025
87b08e3
Update populate_requested_suborg.py
zandercymatics Jan 6, 2025
8e7ffab
Exclude approved
zandercymatics Jan 6, 2025
4fceb62
Update populate_requested_suborg.py
zandercymatics Jan 6, 2025
e91c160
bug fix
zandercymatics Jan 6, 2025
d68ccdc
Finish script
zandercymatics Jan 6, 2025
feb319f
Update populate_requested_suborg.py
zandercymatics Jan 6, 2025
ca9a40c
Add logic for requested suborgs
zandercymatics Jan 7, 2025
2c5c9de
Remove second script, modify first
zandercymatics Jan 7, 2025
7e27492
Remove errant spaces
zandercymatics Jan 7, 2025
d2804a6
Add bulk update
zandercymatics Jan 7, 2025
d06df85
Update test_management_scripts.py
zandercymatics Jan 7, 2025
e55535b
Merge branch 'main' into ag/3234-test-existing-script
zandercymatics Jan 7, 2025
3a356c6
Normalize name and clear fed agency in some cases
zandercymatics Jan 7, 2025
2d163c1
Lint
zandercymatics Jan 7, 2025
2f5e0ec
Code cleanup
zandercymatics Jan 7, 2025
9e49ca4
Simplify logic
zandercymatics Jan 7, 2025
8f3f7f1
Cleanup part 2
zandercymatics Jan 7, 2025
d9cad13
Update create_federal_portfolio.py
zandercymatics Jan 7, 2025
6da5047
Merge branch 'main' into ag/3234-test-existing-script
zandercymatics Jan 7, 2025
5ca74fd
Finish unit tests
zandercymatics Jan 8, 2025
bc92270
Update create_federal_portfolio.py
zandercymatics Jan 8, 2025
b9dc928
lint
zandercymatics Jan 8, 2025
6da172c
Update create_federal_portfolio.py
zandercymatics Jan 8, 2025
1e6a887
Merge branch 'main' into ag/3234-test-existing-script
zandercymatics Jan 8, 2025
983fddd
Update src/registrar/management/commands/create_federal_portfolio.py
zandercymatics Jan 9, 2025
26c3e89
Update src/registrar/management/commands/create_federal_portfolio.py
zandercymatics Jan 9, 2025
f6b4d17
Update src/registrar/management/commands/create_federal_portfolio.py
zandercymatics Jan 9, 2025
fc236c6
Merge branch 'main' into ag/3234-test-existing-script
zandercymatics Jan 13, 2025
5308217
Added better function comment for add_arugments
zandercymatics Jan 13, 2025
f6e94da
Update src/registrar/management/commands/create_federal_portfolio.py
zandercymatics Jan 13, 2025
0f59a63
Lint
zandercymatics Jan 13, 2025
2865dcd
Merge branch 'ag/3234-test-existing-script' of github.com:cisagov/man…
zandercymatics Jan 13, 2025
6a49519
Merge branch 'main' into ag/3234-test-existing-script
zandercymatics Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/registrar/management/commands/create_federal_portfolio.py
Original file line number Diff line number Diff line change
@@ -85,7 +85,6 @@ def handle(self, **options):
TerminalHelper.colorful_logger(logger.info, TerminalColors.MAGENTA, message)
try:
# C901 'Command.handle' is too complex (12)
# We currently only grab the list of changed domain requests, but we may want to grab the domains too
portfolio = self.handle_populate_portfolio(federal_agency, parse_domains, parse_requests, both)
portfolios.append(portfolio)
except Exception as exec:
@@ -105,11 +104,12 @@ def handle(self, **options):

# POST PROCESSING STEP: Remove the federal agency if it matches the portfolio name.
# We only do this for started domain requests.
if parse_requests:
if parse_requests or both:
TerminalHelper.prompt_for_execution(
system_exit_on_terminate=True,
prompt_message="This action will update domain requests even if they aren't on a portfolio.",
prompt_title="Do you want to clear federal agency on started domain requests?",
prompt_title="Do you want to clear federal agency on (related) started domain requests?",
verify_message=None
)
self.post_process_started_domain_requests(agencies, portfolios)

@@ -141,15 +141,18 @@ def post_process_started_domain_requests(self, agencies, portfolios):
if agency_name in portfolio_set:
req.federal_agency = None
updated_requests.append(req)
DomainRequest.objects.bulk_update(updated_requests, ["federal_agency"])

# Log the results
# Execute the update and Log the results
if TerminalHelper.prompt_for_execution(
system_exit_on_terminate=False,
prompt_message=f"Updated {len(updated_requests)} domain requests successfully.",
prompt_title="Do you want to see a list of all changed domain requests?",
prompt_message=(
f"{len(domain_requests_to_update)} domain requests will be updated. "
f"These records will be changed: {[str(req) for req in updated_requests]}"
),
prompt_title="Do wish to commit this update to the database?",
zandercymatics marked this conversation as resolved.
Show resolved Hide resolved
):
logger.info(f"Federal agency set to none on: {[str(request) for request in updated_requests]}")
DomainRequest.objects.bulk_update(updated_requests, ["federal_agency"])
TerminalHelper.colorful_logger(logger.info, TerminalColors.OKBLUE, "Action completed successfully.")

def handle_populate_portfolio(self, federal_agency, parse_domains, parse_requests, both):
"""Attempts to create a portfolio. If successful, this function will