mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
linter fixes
This commit is contained in:
parent
497837b098
commit
f7b2e38bba
3 changed files with 12 additions and 7 deletions
|
@ -3,7 +3,6 @@ from django.core.management import BaseCommand
|
|||
from registrar.management.commands.utility.terminal_helper import PopulateScriptTemplate, TerminalColors
|
||||
from registrar.models import DomainRequest
|
||||
from auditlog.models import LogEntry
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -12,12 +11,13 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
|||
help = "Loops through each domain request object and populates the last_status_update and first_submitted_date"
|
||||
|
||||
def handle(self, **kwargs):
|
||||
"""Loops through each DomainRequest object and populates its last_status_update and first_submitted_date values"""
|
||||
"""Loops through each DomainRequest object and populates
|
||||
its last_status_update and first_submitted_date values"""
|
||||
self.mass_update_records(DomainRequest, None, ["last_status_update", "first_submitted_date"])
|
||||
|
||||
def update_record(self, record: DomainRequest):
|
||||
"""Defines how we update the first_submitted_date and last_status_update fields"""
|
||||
|
||||
|
||||
# Retrieve and order audit log entries by timestamp in descending order
|
||||
audit_log_entries = LogEntry.objects.filter(object_pk=record.pk).order_by("-timestamp")
|
||||
|
||||
|
@ -34,7 +34,10 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
|||
break
|
||||
|
||||
logger.info(
|
||||
f"{TerminalColors.OKCYAN}Updating {record} => first submitted date: " f"{record.first_submitted_date}, last status update:" f"{record.last_status_update}{TerminalColors.ENDC}"
|
||||
f"""{TerminalColors.OKCYAN}Updating {record} =>
|
||||
first submitted date: {record.first_submitted_date},
|
||||
last status update: {record.last_status_update}{TerminalColors.ENDC}
|
||||
"""
|
||||
)
|
||||
|
||||
def should_skip_record(self, record) -> bool:
|
||||
|
|
|
@ -823,7 +823,7 @@ class DomainRequest(TimeStampedModel):
|
|||
if not DraftDomain.string_could_be_domain(self.requested_domain.name):
|
||||
raise ValueError("Requested domain is not a valid domain name.")
|
||||
|
||||
# if the domain has not been submitted before this must be the first time
|
||||
# if the domain has not been submitted before this must be the first time
|
||||
if not self.first_submitted_date:
|
||||
self.first_submitted_date = timezone.now().date()
|
||||
|
||||
|
|
|
@ -287,7 +287,8 @@ class GetRequestsJsonTest(TestWithUser, WebTest):
|
|||
|
||||
def test_sorting(self):
|
||||
"""test that sorting works properly on the result set"""
|
||||
response = self.app.get(reverse("get_domain_requests_json"), {"sort_by": "last_submitted_date", "order": "desc"})
|
||||
response = self.app.get(reverse("get_domain_requests_json"),
|
||||
{"sort_by": "last_submitted_date", "order": "desc"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
data = response.json
|
||||
|
||||
|
@ -306,7 +307,8 @@ class GetRequestsJsonTest(TestWithUser, WebTest):
|
|||
def test_filter_approved_excluded(self):
|
||||
"""test that approved requests are excluded from result set."""
|
||||
# sort in reverse chronological order of submission date, since most recent request is approved
|
||||
response = self.app.get(reverse("get_domain_requests_json"), {"sort_by": "last_submitted_date", "order": "desc"})
|
||||
response = self.app.get(reverse("get_domain_requests_json"),
|
||||
{"sort_by": "last_submitted_date", "order": "desc"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
data = response.json
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue