Work on fixing bugs and reformat
This commit is contained in:
@@ -17,7 +17,7 @@ from django.urls import reverse
|
||||
from django.views import View
|
||||
from mixins.views import ObjectList
|
||||
|
||||
from core.models import Group, Manipulation, Persona, Person
|
||||
from core.models import Group, Manipulation, Person, Persona
|
||||
|
||||
|
||||
def _context_type(request_type: str) -> str:
|
||||
@@ -82,9 +82,7 @@ def _url_with_query(base_url: str, query: dict[str, Any]) -> str:
|
||||
return f"{base_url}?{urlencode(params)}"
|
||||
|
||||
|
||||
def _merge_query(
|
||||
current_query: dict[str, Any], **updates: Any
|
||||
) -> dict[str, Any]:
|
||||
def _merge_query(current_query: dict[str, Any], **updates: Any) -> dict[str, Any]:
|
||||
merged = dict(current_query)
|
||||
for key, value in updates.items():
|
||||
if value is None or str(value).strip() == "":
|
||||
@@ -695,9 +693,7 @@ class OSINTSearch(LoginRequiredMixin, View):
|
||||
per_page_default = 20
|
||||
per_page_max = 100
|
||||
|
||||
def _field_options(
|
||||
self, model_cls: type[models.Model]
|
||||
) -> list[dict[str, str]]:
|
||||
def _field_options(self, model_cls: type[models.Model]) -> list[dict[str, str]]:
|
||||
options = []
|
||||
for field in model_cls._meta.get_fields():
|
||||
# Skip reverse/accessor relations (e.g. ManyToManyRel) that are not
|
||||
@@ -768,16 +764,18 @@ class OSINTSearch(LoginRequiredMixin, View):
|
||||
if isinstance(field, models.ForeignKey):
|
||||
related_text_field = _preferred_related_text_field(field.related_model)
|
||||
if related_text_field:
|
||||
return Q(
|
||||
**{f"{field_name}__{related_text_field}__icontains": query}
|
||||
), False
|
||||
return (
|
||||
Q(**{f"{field_name}__{related_text_field}__icontains": query}),
|
||||
False,
|
||||
)
|
||||
return Q(**{f"{field_name}__id__icontains": query}), False
|
||||
if isinstance(field, models.ManyToManyField):
|
||||
related_text_field = _preferred_related_text_field(field.related_model)
|
||||
if related_text_field:
|
||||
return Q(
|
||||
**{f"{field_name}__{related_text_field}__icontains": query}
|
||||
), True
|
||||
return (
|
||||
Q(**{f"{field_name}__{related_text_field}__icontains": query}),
|
||||
True,
|
||||
)
|
||||
return Q(**{f"{field_name}__id__icontains": query}), True
|
||||
return None, False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user