From 75f4e7f4b17ef0c475bd25768e51537627641c02 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:30:08 -0700 Subject: [PATCH] PR changes --- docs/operations/data_migration.md | 2 +- .../commands/load_transition_domain.py | 19 +++++--- .../utility/extra_transition_domain_helper.py | 10 +++-- .../commands/utility/terminal_helper.py | 44 ------------------- src/registrar/models/domain_information.py | 1 + 5 files changed, 21 insertions(+), 55 deletions(-) diff --git a/docs/operations/data_migration.md b/docs/operations/data_migration.md index 3f97511f3..38411e372 100644 --- a/docs/operations/data_migration.md +++ b/docs/operations/data_migration.md @@ -246,7 +246,7 @@ This will allow Docker to mount the files to a container (under `/app`) for our *You are now ready to run migration scripts.* ## Transition Domains (Part 2) - Running the Migration Scripts -While keeping the same ssh instance open (if you are running on a sandbox), run through the following commands. If you run into the error that. If you cannot run `manage.py` commands, try running `/tmp/lifecycle/shell` in the ssh instance. +While keeping the same ssh instance open (if you are running on a sandbox), run through the following commands.If you cannot run `manage.py` commands, try running `/tmp/lifecycle/shell` in the ssh instance. ### STEP 1: Load Transition Domains diff --git a/src/registrar/management/commands/load_transition_domain.py b/src/registrar/management/commands/load_transition_domain.py index 4b48298ae..79fe83022 100644 --- a/src/registrar/management/commands/load_transition_domain.py +++ b/src/registrar/management/commands/load_transition_domain.py @@ -5,6 +5,7 @@ import logging import argparse from collections import defaultdict +from django.conf import settings from django.core.management import BaseCommand from registrar.management.commands.utility.epp_data_containers import EnumFilenames @@ -63,12 +64,15 @@ class Command(BaseCommand): action=argparse.BooleanOptionalAction, ) - parser.add_argument( - "--infer_filenames", - action=argparse.BooleanOptionalAction, - help="Determines if we should infer filenames or not." - "Recommended to be enabled only in a development or testing setting.", - ) + # This option should only be available when developing locally. + # This should not be available to the end user. + if settings.DEBUG: + parser.add_argument( + "--infer_filenames", + action=argparse.BooleanOptionalAction, + help="Determines if we should infer filenames or not." + "Recommended to be enabled only in a development or testing setting.", + ) parser.add_argument( "--directory", default="migrationdata", help="Desired directory" @@ -322,6 +326,9 @@ class Command(BaseCommand): **options, ): """Parse the data files and create TransitionDomains.""" + if not settings.DEBUG: + options["infer_filenames"] = False + args = TransitionDomainArguments(**options) # Desired directory for additional TransitionDomain data diff --git a/src/registrar/management/commands/utility/extra_transition_domain_helper.py b/src/registrar/management/commands/utility/extra_transition_domain_helper.py index 89e50742e..eb73125e1 100644 --- a/src/registrar/management/commands/utility/extra_transition_domain_helper.py +++ b/src/registrar/management/commands/utility/extra_transition_domain_helper.py @@ -334,12 +334,11 @@ class LoadExtraTransitionDomain: if not isinstance(info.isfederal, str) or not info.isfederal.lower() == "y": self.parse_logs.create_log_item( EnumFilenames.DOMAIN_ADHOC, - LogCode.ERROR, - f"Could not add non-federal agency {info.agencyname} on {domain_name}", + LogCode.INFO, + f"Adding non-federal agency {info.agencyname} on {domain_name}", domain_name, not self.debug, ) - return transition_domain transition_domain.federal_agency = info.agencyname @@ -685,6 +684,10 @@ class FileDataHolder: # Object data # self.data: Dict[str, type] = {} + # This is used ONLY for development purposes. This behaviour + # is controlled by the --infer_filename flag which is defaulted + # to false. The purpose of this check is to speed up development, + # but it cannot be used by the enduser def try_infer_filename(self, current_file_name, default_file_name): """Tries to match a given filename to a regex, then uses that match to generate the filename.""" @@ -850,7 +853,6 @@ class ExtraTransitionDomain: infer_filenames: bool -> Determines if we should try to infer the filename if a default is passed in """ - self.clear_file_data() for name, value in self.file_data.items(): is_domain_escrow = name == EnumFilenames.DOMAIN_ESCROW filename = f"{value.filename}" diff --git a/src/registrar/management/commands/utility/terminal_helper.py b/src/registrar/management/commands/utility/terminal_helper.py index b38176172..56e0b2bc6 100644 --- a/src/registrar/management/commands/utility/terminal_helper.py +++ b/src/registrar/management/commands/utility/terminal_helper.py @@ -213,47 +213,3 @@ class TerminalHelper: ) with open(f"{filepath}", "w+") as f: f.write(file_contents) - - @staticmethod - def printProgressBar( - iteration, - total, - prefix="Progress:", - suffix="Complete", - decimals=1, - length=100, - fill="█", - printEnd="\r", - ): - """ - Call in a loop to create terminal progress bar - @params: - iteration - Required : current iteration (Int) - total - Required : total iterations (Int) - prefix - Optional : prefix string (Str) - suffix - Optional : suffix string (Str) - decimals - Optional : positive number of decimals in percent complete (Int) - length - Optional : character length of bar (Int) - fill - Optional : bar fill character (Str) - printEnd - Optional : end character (e.g. "\r", "\r\n") (Str) - """ # noqa - - """ - # Initial call to print 0% progress - printProgressBar(0, l, prefix = 'Progress:', suffix = 'Complete', length = 50) - for i, item in enumerate(items): - # Do stuff... - time.sleep(0.1) - # Update Progress Bar - printProgressBar(i + 1, l, prefix = 'Progress:', suffix = 'Complete', length = 50) - """ # noqa - - percent = ("{0:." + str(decimals) + "f}").format( - 100 * (iteration / float(total)) - ) - filledLength = int(length * iteration // total) - bar = fill * filledLength + "-" * (length - filledLength) - print(f"\r{prefix} |{bar}| {percent}% {suffix}", end=printEnd) - # Print New Line on Complete - if iteration == total: - print() diff --git a/src/registrar/models/domain_information.py b/src/registrar/models/domain_information.py index 377d75685..73d724815 100644 --- a/src/registrar/models/domain_information.py +++ b/src/registrar/models/domain_information.py @@ -54,6 +54,7 @@ class DomainInformation(TimeStampedModel): blank=True, help_text="Type of Organization", ) + federally_recognized_tribe = models.BooleanField( null=True, help_text="Is the tribe federally recognized",