mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 14:04:10 +02:00
linter fixes
This commit is contained in:
parent
f6e10b6585
commit
febd9566ce
2 changed files with 14 additions and 14 deletions
|
@ -4,14 +4,16 @@ from django.db.models.manager import BaseManager
|
||||||
from registrar.management.commands.utility.terminal_helper import PopulateScriptTemplate, TerminalColors
|
from registrar.management.commands.utility.terminal_helper import PopulateScriptTemplate, TerminalColors
|
||||||
from registrar.models import Domain, TransitionDomain
|
from registrar.models import Domain, TransitionDomain
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand, PopulateScriptTemplate):
|
class Command(BaseCommand, PopulateScriptTemplate):
|
||||||
help = "Loops through each domain object and populates the last_status_update and first_submitted_date"
|
help = "Loops through each domain object and populates the last_status_update and first_submitted_date"
|
||||||
|
|
||||||
def handle(self, **kwargs):
|
def handle(self, **kwargs):
|
||||||
"""Loops through each valid Domain object and updates it's first_ready value if it is out of sync"""
|
"""Loops through each valid Domain object and updates it's first_ready value if it is out of sync"""
|
||||||
filter_conditions={"state__in":[Domain.State.READY, Domain.State.ON_HOLD, Domain.State.DELETED, Domain.State.UNKNOWN]}
|
filter_conditions = {"state__in": [Domain.State.READY, Domain.State.ON_HOLD, Domain.State.DELETED]}
|
||||||
self.mass_update_records(Domain, filter_conditions, ["first_ready"], verbose=True)
|
self.mass_update_records(Domain, filter_conditions, ["first_ready"], verbose=True)
|
||||||
|
|
||||||
def update_record(self, record: Domain):
|
def update_record(self, record: Domain):
|
||||||
|
@ -28,7 +30,7 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
||||||
def custom_filter(self, records: BaseManager[Domain]) -> BaseManager[Domain]:
|
def custom_filter(self, records: BaseManager[Domain]) -> BaseManager[Domain]:
|
||||||
to_include_pks = []
|
to_include_pks = []
|
||||||
for record in records:
|
for record in records:
|
||||||
if TransitionDomain.objects.filter(domain_name=record.name).exists() and record.first_ready != record.created_at.date():
|
if TransitionDomain.objects.filter(domain_name=record.name).exists() and record.first_ready != record.created_at.date(): #noqa
|
||||||
to_include_pks.append(record.pk)
|
to_include_pks.append(record.pk)
|
||||||
|
|
||||||
return records.filter(pk__in=to_include_pks)
|
return records.filter(pk__in=to_include_pks)
|
|
@ -118,13 +118,13 @@ class PopulateScriptTemplate(ABC):
|
||||||
readable_class_name = self.get_class_name(object_class)
|
readable_class_name = self.get_class_name(object_class)
|
||||||
|
|
||||||
# for use in the execution prompt.
|
# for use in the execution prompt.
|
||||||
proposed_changes=f"""==Proposed Changes==
|
proposed_changes = f"""==Proposed Changes==
|
||||||
Number of {readable_class_name} objects to change: {len(records)}
|
Number of {readable_class_name} objects to change: {len(records)}
|
||||||
These fields will be updated on each record: {fields_to_update}
|
These fields will be updated on each record: {fields_to_update}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
proposed_changes=f"""{proposed_changes}
|
proposed_changes = f"""{proposed_changes}
|
||||||
These records will be updated: {list(records.all())}
|
These records will be updated: {list(records.all())}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -187,8 +187,6 @@ class PopulateScriptTemplate(ABC):
|
||||||
Applied to individual records *after* filter_conditions. True means """
|
Applied to individual records *after* filter_conditions. True means """
|
||||||
return records
|
return records
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TerminalHelper:
|
class TerminalHelper:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def log_script_run_summary(
|
def log_script_run_summary(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue