update search_by_item and show_order
This commit is contained in:
@@ -4,6 +4,7 @@ from aiogram.fsm.state import State, StatesGroup
|
|||||||
class SearchForm(StatesGroup):
|
class SearchForm(StatesGroup):
|
||||||
search_option = State()
|
search_option = State()
|
||||||
data_to_search = State()
|
data_to_search = State()
|
||||||
|
sent_messages = State()
|
||||||
search_result = State()
|
search_result = State()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -132,14 +132,6 @@ async def search_by_item(message: Message, state: FSMContext):
|
|||||||
async def show_order(callback: CallbackQuery, state: FSMContext, bot: Bot):
|
async def show_order(callback: CallbackQuery, state: FSMContext, bot: Bot):
|
||||||
order_id = int(re.search(r"(\d+)", callback.data).group())
|
order_id = int(re.search(r"(\d+)", callback.data).group())
|
||||||
|
|
||||||
try:
|
|
||||||
async with async_session_() as local_session:
|
|
||||||
result = await local_session.execute(select(Order).filter(Order.id == order_id))
|
|
||||||
order = result.scalars().first()
|
|
||||||
|
|
||||||
except Exception as err:
|
|
||||||
logger.warning(err)
|
|
||||||
|
|
||||||
order = next(filter(lambda item: order_id == item.id, await state.get_value("search_result")), None)
|
order = next(filter(lambda item: order_id == item.id, await state.get_value("search_result")), None)
|
||||||
|
|
||||||
if order:
|
if order:
|
||||||
|
|||||||
Reference in New Issue
Block a user