def back_to_the_catalog(chat_id, language, message_text=None, parent_category=None): bot.send_chat_action(chat_id, 'typing') if not message_text: catalog_message = strings.get_string('catalog.start', language) else: catalog_message = message_text if parent_category: catalog_message = strings.from_category_name(parent_category, language) categories = parent_category.get_siblings(include_self=True).all() category_keyboard = keyboards.from_dish_categories( categories, language) bot.send_message(chat_id, catalog_message, reply_markup=category_keyboard) if parent_category.parent: bot.register_next_step_handler_by_chat_id( chat_id, catalog_processor, parent_category=parent_category.parent) else: bot.register_next_step_handler_by_chat_id(chat_id, catalog_processor) return categories = dishservice.get_parent_categories(sort_by_number=True) category_keyboard = keyboards.from_dish_categories(categories, language) bot.send_message(chat_id, catalog_message, reply_markup=category_keyboard, parse_mode='HTML') bot.register_next_step_handler_by_chat_id(chat_id, catalog_processor)
def catalog(message: Message): chat_id = message.chat.id user_id = message.from_user.id language = userservice.get_user_language(user_id) bot.send_chat_action(chat_id, 'typing') catalog_message = strings.get_string('catalog.start', language) categories = dishservice.get_parent_categories(sort_by_number=True) if len(categories) == 0: empty_message = strings.get_string('catalog.empty', language) bot.send_message(chat_id, empty_message) return category_keyboard = keyboards.from_dish_categories(categories, language) bot.send_message(chat_id, catalog_message, reply_markup=category_keyboard) bot.register_next_step_handler_by_chat_id(chat_id, catalog_processor)
def catalog(): categories = dishservice.get_parent_categories(sort_by_number=True) return render_template('admin/catalog.html', title='Каталог', area='catalog', categories=categories)