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.contrib.contenttypes.models import ContentType
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
from django.urls import reverse
|
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
|
# Split up for the linter
|
||||||
from registrar.models.utility.admin_form_order_helper import SortingDict
|
from registrar.models.utility.admin_form_order_helper import SortingDict
|
||||||
from . import models
|
from . import models
|
||||||
|
|
|
@ -6,6 +6,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SortingDict:
|
class SortingDict:
|
||||||
|
"""Stores a sorting dictionary object"""
|
||||||
_sorting_dict: Dict[type, type] = {}
|
_sorting_dict: Dict[type, type] = {}
|
||||||
|
|
||||||
# model_list can be will be called multiple times.
|
# model_list can be will be called multiple times.
|
||||||
|
@ -14,6 +15,7 @@ class SortingDict:
|
||||||
# while minimizing typing when
|
# while minimizing typing when
|
||||||
# adding a new SortingDict (input as a list)
|
# adding a new SortingDict (input as a list)
|
||||||
def convert_list_to_dict(self, value_list):
|
def convert_list_to_dict(self, value_list):
|
||||||
|
"""Used internally to convert model_list to a dictionary"""
|
||||||
dictionary: Dict[type, type] = {}
|
dictionary: Dict[type, type] = {}
|
||||||
for item in value_list:
|
for item in value_list:
|
||||||
dictionary[item] = item
|
dictionary[item] = item
|
||||||
|
@ -26,6 +28,8 @@ class SortingDict:
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_dict(self):
|
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
|
# This should never happen so we need to log this
|
||||||
if self._sorting_dict is None:
|
if self._sorting_dict is None:
|
||||||
raise ValueError("_sorting_dict was 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
|
# Used to keep track of how we want to order_by certain FKs
|
||||||
_sorting_list: list[SortingDict] = []
|
_sorting_list: list[SortingDict] = []
|
||||||
|
|
||||||
def __init__(self, sort):
|
def __init__(self, sort: list[SortingDict]):
|
||||||
self._sorting_list = sort
|
self._sorting_list = sort
|
||||||
|
|
||||||
def get_ordered_form_field(self, form_field, db_field) -> (ModelChoiceField | None):
|
def get_ordered_form_field(self, form_field, db_field) -> (ModelChoiceField | None):
|
||||||
|
|
|
@ -583,6 +583,7 @@ class AuditedAdminTest(TestCase):
|
||||||
field_name,
|
field_name,
|
||||||
queryset_shorthand
|
queryset_shorthand
|
||||||
):
|
):
|
||||||
|
"""Handles edge cases for test cases"""
|
||||||
if first_name is None:
|
if first_name is None:
|
||||||
raise ValueError('Invalid value for first_name, must be defined')
|
raise ValueError('Invalid value for first_name, must be defined')
|
||||||
|
|
||||||
|
@ -591,7 +592,7 @@ class AuditedAdminTest(TestCase):
|
||||||
if last_name is None:
|
if last_name is None:
|
||||||
return (first_name,)
|
return (first_name,)
|
||||||
|
|
||||||
if(first_name.split(queryset_shorthand)[1] == field_name):
|
if (first_name.split(queryset_shorthand)[1] == field_name):
|
||||||
return returned_tuple
|
return returned_tuple
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue