catalogue operations, db migr and so on.
pre release version.
This commit is contained in:
@@ -26,15 +26,16 @@ async def subcatalogue(
|
||||
|
||||
view = await catalogue_service.build_category_view(session, cat_id)
|
||||
kb = render_catalogue(view, is_admin=is_admin)
|
||||
path = await catalogue_service.get_path(session, cat_id)
|
||||
|
||||
if cb.message.photo:
|
||||
await cb.message.delete()
|
||||
await cb.answer(
|
||||
"category selection",
|
||||
await cb.message.answer(
|
||||
f"{path}",
|
||||
reply_markup=kb,
|
||||
)
|
||||
return
|
||||
await cb.message.edit_text(
|
||||
"category selection",
|
||||
f"{path}",
|
||||
reply_markup=kb,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import os
|
||||
import logging
|
||||
from re import Match
|
||||
from aiogram import Router, F
|
||||
from aiogram.types import CallbackQuery, FSInputFile
|
||||
from aiogram.exceptions import TelegramBadRequest
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -17,6 +19,7 @@ from services.catalogue import CatalogueService
|
||||
from services.orders import OrderService
|
||||
|
||||
router = Router()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@router.callback_query(
|
||||
@@ -73,17 +76,9 @@ async def product_card(
|
||||
cart_amount=order_item,
|
||||
)
|
||||
|
||||
if product.file_id:
|
||||
await cb.message.delete()
|
||||
|
||||
msg = await cb.message.answer_photo(
|
||||
product.file_id,
|
||||
caption=get_product_description(product),
|
||||
reply_markup=kb,
|
||||
)
|
||||
return
|
||||
|
||||
if not os.path.isfile(product.img_path):
|
||||
if not product.file_id and not (
|
||||
product.img_path and os.path.isfile(product.img_path)
|
||||
):
|
||||
await cb.message.edit_text(
|
||||
get_product_description(product),
|
||||
reply_markup=kb,
|
||||
@@ -91,6 +86,20 @@ async def product_card(
|
||||
return
|
||||
|
||||
await cb.message.delete()
|
||||
|
||||
if product.file_id:
|
||||
msg = await cb.message.answer_photo(
|
||||
product.file_id,
|
||||
caption=get_product_description(product),
|
||||
reply_markup=kb,
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
await cb.message.edit_text("<b>⏳ Загружаем карточку товара...</b>")
|
||||
except TelegramBadRequest:
|
||||
...
|
||||
|
||||
msg = await cb.message.answer_photo(
|
||||
FSInputFile(product.img_path),
|
||||
caption=get_product_description(product),
|
||||
@@ -98,6 +107,7 @@ async def product_card(
|
||||
)
|
||||
|
||||
if not msg.photo:
|
||||
logger.warning("didnt get a photo back wahhh :(")
|
||||
return # TODO: Add logging
|
||||
|
||||
await products_repo.add_product_file_id(
|
||||
|
||||
Reference in New Issue
Block a user