diff --git a/frontend/templates/cat_list.html.j2 b/frontend/templates/cat_list.html.j2
index 3d10f7c..ea6bcc9 100644
--- a/frontend/templates/cat_list.html.j2
+++ b/frontend/templates/cat_list.html.j2
@@ -4,7 +4,7 @@
Cat list ({{ cat_list | length }})
+
diff --git a/mewgenics_heredity/app.py b/mewgenics_heredity/app.py
index e80bd6d..200b389 100644
--- a/mewgenics_heredity/app.py
+++ b/mewgenics_heredity/app.py
@@ -4,6 +4,7 @@ from litestar.plugins.htmx import HTMXPlugin
from litestar.contrib.jinja import JinjaTemplateEngine
from litestar.template.config import TemplateConfig
from litestar.static_files import create_static_files_router
+from advanced_alchemy.extensions.litestar import EngineConfig
from pathlib import Path
from .config import config
from .controllers import CatController, FrontendController, GenerationController
diff --git a/mewgenics_heredity/controllers/FrontendController.py b/mewgenics_heredity/controllers/FrontendController.py
index 8503f94..f5fdbf3 100644
--- a/mewgenics_heredity/controllers/FrontendController.py
+++ b/mewgenics_heredity/controllers/FrontendController.py
@@ -1,9 +1,11 @@
from uuid import UUID
+import itertools
from litestar import Controller, get, post
from litestar.di import Provide
from litestar.response import Template
from litestar.plugins.htmx import HTMXRequest, HTMXTemplate
-from advanced_alchemy.filters import OrderBy, LimitOffset, CollectionFilter
+from advanced_alchemy.filters import OrderBy, LimitOffset, CollectionFilter, ComparisonFilter, FilterGroup, LogicalOperatorMap
+from sqlalchemy import or_
from pprint import pprint
from ..models import Cat, CatRepository, StateEnum, SexEnum
@@ -40,6 +42,7 @@ class FrontendController(Controller):
async def cat_list(
self,
cats_repo: CatRepository,
+ fltr_parent: list[str] | None = None,
state_filters: list[str] | None = None,
sortby: str = 'name',
sortorder: str = 'asc',
@@ -58,6 +61,18 @@ class FrontendController(Controller):
)
)
+ if fltr_parent:
+ for parent_id in map(UUID, filter(bool, fltr_parent)):
+ filters.append(
+ FilterGroup(
+ or_,
+ [
+ ComparisonFilter(Cat.parent_a, 'eq', parent_id),
+ ComparisonFilter(Cat.parent_b, 'eq', parent_id),
+ ]
+ )
+ )
+
elts = await cats_repo.list(
*filters,
OrderBy(sortby, sortorder)
@@ -77,6 +92,33 @@ class FrontendController(Controller):
}
)
+ @get(path='/hx/get_parent_cat_options')
+ async def get_parent_cat_options(
+ self,
+ cats_repo: CatRepository,
+ ) -> Template:
+ all_cats = await cats_repo.list()
+ parent_ids = set(itertools.chain.from_iterable([ (cat.parent_a, cat.parent_b) for cat in all_cats ]))
+ parent_cats = list(
+ filter(
+ lambda elt: elt.id in parent_ids,
+ all_cats
+ )
+ )
+
+ return HTMXTemplate(
+ template_name='templates/cat_options.html.j2',
+ context={
+ 'cat_list': parent_cats
+ },
+ re_target="this",
+ after="receive"
+ )
+
+
+
+
+
"""
@get(path='/hx/cat_form')
async def get_hx_cat_form(self,