mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 17:47:02 +02:00
Why must the linter lint?
This commit is contained in:
parent
ed26035763
commit
080a70e613
4 changed files with 13 additions and 8 deletions
|
@ -4,7 +4,7 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from registrar.models.utility.admin_form_order_helper import AdminFormOrderHelper, SortingDict
|
||||
from registrar.models.utility.admin_form_order_helper import AdminFormOrderHelper
|
||||
# Split up for the linter
|
||||
from registrar.models.utility.admin_form_order_helper import SortingDict
|
||||
from . import models
|
||||
|
@ -16,13 +16,13 @@ foreignkey_orderby_dict: list[SortingDict] = [
|
|||
# foreign_key - order_by
|
||||
# Handles fields that are sorted by 'first_name / last_name
|
||||
SortingDict(
|
||||
["submitter", "authorizing_official", "investigator", "creator", "user"],
|
||||
['first_name', 'last_name']
|
||||
["submitter", "authorizing_official", "investigator", "creator", "user"],
|
||||
['first_name', 'last_name']
|
||||
),
|
||||
# Handles fields that are sorted by 'name'
|
||||
SortingDict(
|
||||
["domain", "requested_domain"],
|
||||
["name"]
|
||||
["domain", "requested_domain"],
|
||||
["name"]
|
||||
)
|
||||
]
|
||||
|
||||
|
|
|
@ -246,4 +246,4 @@ class DomainInformation(TimeStampedModel):
|
|||
return domain_info
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Domain Information"
|
||||
verbose_name_plural = "Domain Information"
|
||||
|
|
|
@ -6,6 +6,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class SortingDict:
|
||||
"""Stores a sorting dictionary object"""
|
||||
_sorting_dict: Dict[type, type] = {}
|
||||
|
||||
# model_list can be will be called multiple times.
|
||||
|
@ -14,6 +15,7 @@ class SortingDict:
|
|||
# while minimizing typing when
|
||||
# adding a new SortingDict (input as a list)
|
||||
def convert_list_to_dict(self, value_list):
|
||||
"""Used internally to convert model_list to a dictionary"""
|
||||
dictionary: Dict[type, type] = {}
|
||||
for item in value_list:
|
||||
dictionary[item] = item
|
||||
|
@ -26,6 +28,8 @@ class SortingDict:
|
|||
}
|
||||
|
||||
def get_dict(self):
|
||||
"""Grabs the associated dictionary item,
|
||||
has two fields: 'dropDownSelected': model_list and 'sortBy': sort_list"""
|
||||
# This should never happen so we need to log this
|
||||
if self._sorting_dict is None:
|
||||
raise ValueError("_sorting_dict was None")
|
||||
|
@ -39,7 +43,7 @@ class AdminFormOrderHelper():
|
|||
# Used to keep track of how we want to order_by certain FKs
|
||||
_sorting_list: list[SortingDict] = []
|
||||
|
||||
def __init__(self, sort):
|
||||
def __init__(self, sort: list[SortingDict]):
|
||||
self._sorting_list = sort
|
||||
|
||||
def get_ordered_form_field(self, form_field, db_field) -> (ModelChoiceField | None):
|
||||
|
|
|
@ -583,6 +583,7 @@ class AuditedAdminTest(TestCase):
|
|||
field_name,
|
||||
queryset_shorthand
|
||||
):
|
||||
"""Handles edge cases for test cases"""
|
||||
if first_name is None:
|
||||
raise ValueError('Invalid value for first_name, must be defined')
|
||||
|
||||
|
@ -591,7 +592,7 @@ class AuditedAdminTest(TestCase):
|
|||
if last_name is None:
|
||||
return (first_name,)
|
||||
|
||||
if(first_name.split(queryset_shorthand)[1] == field_name):
|
||||
if (first_name.split(queryset_shorthand)[1] == field_name):
|
||||
return returned_tuple
|
||||
else:
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue