catalogue operations, db migr and so on.

pre release version.
This commit is contained in:
2026-03-11 20:26:38 +07:00
parent 1af0cf1826
commit 7f4f8a883d
17 changed files with 284 additions and 63 deletions

View File

@@ -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(