From 9f29509d9217fc30af9da419be10b6106f18b5da Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:03:11 -0600 Subject: [PATCH] PR suggestions --- .../commands/transfer_federal_agency_type.py | 6 ++---- .../management/commands/utility/terminal_helper.py | 13 +++++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/registrar/management/commands/transfer_federal_agency_type.py b/src/registrar/management/commands/transfer_federal_agency_type.py index 5d7bb443e..ca4360527 100644 --- a/src/registrar/management/commands/transfer_federal_agency_type.py +++ b/src/registrar/management/commands/transfer_federal_agency_type.py @@ -10,14 +10,12 @@ logger = logging.getLogger(__name__) class Command(BaseCommand, PopulateScriptTemplate): """ - This command uses the PopulateScriptTemplate. - This template handles logging and bulk updating for you, for repetitive scripts that update a few fields. - It is the ultimate lazy mans shorthand. Don't use this for anything terribly complicated. + This command uses the PopulateScriptTemplate, + which provides reusable logging and bulk updating functions for mass-updating fields. """ help = "Loops through each valid User object and updates its verification_type value" prompt_title = "Do you wish to update all Federal Agencies?" - display_run_summary_items_as_str = True def handle(self, **kwargs): """Loops through each valid User object and updates the value of its verification_type field""" diff --git a/src/registrar/management/commands/utility/terminal_helper.py b/src/registrar/management/commands/utility/terminal_helper.py index eedc09aae..82821bd70 100644 --- a/src/registrar/management/commands/utility/terminal_helper.py +++ b/src/registrar/management/commands/utility/terminal_helper.py @@ -59,21 +59,18 @@ class ScriptDataHelper: model_class.objects.bulk_update(page.object_list, fields_to_update) -# This template handles logging and bulk updating for you, for repetitive scripts that update a few fields. -# It is the ultimate lazy mans shorthand. Don't use this for anything terribly complicated. -# See the transfer_federal_agency.py file for example usage - its really quite simple! class PopulateScriptTemplate(ABC): """ - Contains an ABC for generic populate scripts + Contains an ABC for generic populate scripts. + + This template provides reusable logging and bulk updating functions for + mass-updating fields. """ # Optional script-global config variables. For the most part, you can leave these untouched. # Defines what prompt_for_execution displays as its header when you first start the script prompt_title: str = "Do you wish to proceed?" - # Runs str(item) over each item when printing. Use this for prettier run summaries. - display_run_summary_items_as_str: bool = False - # The header when printing the script run summary (after the script finishes) run_summary_header = None @@ -130,7 +127,7 @@ class PopulateScriptTemplate(ABC): to_skip, debug=debug, log_header=self.run_summary_header, - display_as_str=self.display_run_summary_items_as_str, + display_as_str=True, ) def get_class_name(self, sender) -> str: