mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 18:25:58 +02:00
PR suggestions
This commit is contained in:
parent
ed441c6c1a
commit
9f29509d92
2 changed files with 7 additions and 12 deletions
|
@ -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"""
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue