product management, unification of kb and so on.
This commit is contained in:
@@ -29,7 +29,9 @@ async def subcatalogue(
|
||||
|
||||
if cat_id == "root":
|
||||
children = await categories_repo.get_categories_by_parent_id(session)
|
||||
kb = render_category(children, show_menu=True)
|
||||
kb = render_category(
|
||||
children, show_menu=True, category_cb_factory=lambda c: f"cat:{c.id}"
|
||||
)
|
||||
await cb.message.edit_text(
|
||||
"category selection",
|
||||
reply_markup=kb,
|
||||
@@ -61,11 +63,14 @@ async def subcatalogue(
|
||||
"hya",
|
||||
reply_markup=render_products(
|
||||
products[:PAGE_SIZE],
|
||||
parent_id=parent_id,
|
||||
cat_id=cat_id,
|
||||
page=0,
|
||||
show_prev=products_len < 0,
|
||||
show_next=products_len > PAGE_SIZE,
|
||||
product_cb_factory=lambda p: f"product:{p.id}",
|
||||
back_cb=f"cat:{parent_id}",
|
||||
next_cb=(
|
||||
f"products:{cat_id}:{0 + 1}"
|
||||
if products_len > PAGE_SIZE
|
||||
else None
|
||||
),
|
||||
columns=2,
|
||||
),
|
||||
)
|
||||
return
|
||||
@@ -74,16 +79,20 @@ async def subcatalogue(
|
||||
"hya",
|
||||
reply_markup=render_products(
|
||||
products[:PAGE_SIZE],
|
||||
parent_id=parent_id,
|
||||
cat_id=cat_id,
|
||||
page=0,
|
||||
show_prev=products_len < 0,
|
||||
show_next=products_len > PAGE_SIZE,
|
||||
product_cb_factory=lambda p: f"product:{p.id}",
|
||||
back_cb=f"cat:{parent_id}",
|
||||
prev_cb=f"products:{cat_id}:{0 - 1}" if products_len < 0 else None,
|
||||
next_cb=(
|
||||
f"products:{cat_id}:{0 + 1}" if products_len > PAGE_SIZE else None
|
||||
),
|
||||
columns=2,
|
||||
),
|
||||
)
|
||||
return
|
||||
|
||||
kb = render_category(children, parent_id)
|
||||
kb = render_category(
|
||||
children, parent_id, category_cb_factory=lambda c: f"cat:{c.id}"
|
||||
)
|
||||
|
||||
await cb.message.edit_text(
|
||||
"category selection",
|
||||
|
||||
Reference in New Issue
Block a user