stop inv button
This commit is contained in:
parent
449c023dff
commit
e01a416c76
|
@ -95,6 +95,7 @@ class TgBot:
|
|||
self.inv,
|
||||
)
|
||||
)
|
||||
TgBot.app.add_handler(CallbackQueryHandler(self.stop_inv, "stop_inv"))
|
||||
TgBot.app.add_handler(CallbackQueryHandler(self.get_inv, r"get_inv@(.*?)"))
|
||||
TgBot.app.add_handler(CallbackQueryHandler(self.add_tmc, r"add_tmc@(.*?)"))
|
||||
TgBot.app.add_handler(
|
||||
|
@ -151,13 +152,26 @@ class TgBot:
|
|||
return f"Инвентаризация `{inv.name}` от `{inv.created_at.strftime('%x')}`"
|
||||
|
||||
def format_tmc_count(self, tmc_count):
|
||||
return f"Количество ТМЦ {tmc_count}\n"
|
||||
return f"Количество ТМЦ {tmc_count}"
|
||||
|
||||
def format_tmc_name(self, tmc):
|
||||
return f"Название ТМЦ `{tmc.name}`\n"
|
||||
return f"Название ТМЦ `{tmc.name}`"
|
||||
|
||||
def format_element(self, field):
|
||||
return f"Элемент `{field.name}`\n"
|
||||
return f"Элемент `{field.name}`"
|
||||
|
||||
def stop_inv_button(self):
|
||||
return [
|
||||
InlineKeyboardButton(
|
||||
"❌❌❌ Остановить инвентаризацию", callback_data="stop_inv"
|
||||
)
|
||||
]
|
||||
|
||||
async def stop_inv(self, update: Update, context: CallbackContext):
|
||||
query = update.callback_query
|
||||
await update.effective_message.edit_reply_markup(InlineKeyboardMarkup([]))
|
||||
await query.answer()
|
||||
context.chat_data.clear()
|
||||
|
||||
async def get_inv(self, update: Update, context: CallbackContext):
|
||||
query = update.callback_query
|
||||
|
@ -244,19 +258,14 @@ class TgBot:
|
|||
context.chat_data["inv"] = inv.id
|
||||
context.chat_data["step"] = "add_tmc"
|
||||
|
||||
await update.effective_message.reply_markdown_v2(
|
||||
"\n".join(
|
||||
text = "\n".join(
|
||||
[
|
||||
self.format_inv(inv),
|
||||
self.format_tmc_count(await inv.tmc.acount()),
|
||||
"Выберите, какую ТМЦ вы осматриваете:",
|
||||
]
|
||||
),
|
||||
reply_parameters=ReplyParameters(
|
||||
message_id=update.effective_message.message_id
|
||||
),
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
)
|
||||
keyboard = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
i["name"],
|
||||
|
@ -266,7 +275,14 @@ class TgBot:
|
|||
]
|
||||
for arr in keys
|
||||
]
|
||||
keyboard.append(self.stop_inv_button())
|
||||
|
||||
await update.effective_message.reply_markdown_v2(
|
||||
text,
|
||||
reply_parameters=ReplyParameters(
|
||||
message_id=update.effective_message.message_id
|
||||
),
|
||||
reply_markup=InlineKeyboardMarkup(keyboard),
|
||||
)
|
||||
|
||||
elif current_step == "add_tmc":
|
||||
|
@ -283,20 +299,15 @@ class TgBot:
|
|||
context.chat_data["tmc"] = tmc_element.id
|
||||
context.chat_data["step"] = "add_element"
|
||||
|
||||
await update.effective_message.reply_markdown_v2(
|
||||
"\n".join(
|
||||
text = "\n".join(
|
||||
[
|
||||
self.format_inv(inv),
|
||||
self.format_tmc_count(await inv.tmc.acount()),
|
||||
self.format_tmc_name(tmc),
|
||||
f"Что вы загружаете?",
|
||||
]
|
||||
),
|
||||
reply_parameters=ReplyParameters(
|
||||
message_id=update.effective_message.message_id
|
||||
),
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
)
|
||||
keyboard = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
i["name"],
|
||||
|
@ -306,7 +317,14 @@ class TgBot:
|
|||
]
|
||||
for arr in keys
|
||||
]
|
||||
keyboard.append(self.stop_inv_button())
|
||||
|
||||
await update.effective_message.reply_markdown_v2(
|
||||
text,
|
||||
reply_parameters=ReplyParameters(
|
||||
message_id=update.effective_message.message_id
|
||||
),
|
||||
reply_markup=InlineKeyboardMarkup(keyboard),
|
||||
)
|
||||
|
||||
elif current_step == "add_element":
|
||||
|
@ -316,6 +334,7 @@ class TgBot:
|
|||
field = await BaseCustomField.objects.aget(id=element.field_id)
|
||||
|
||||
context.chat_data["step"] = "add_element_data"
|
||||
|
||||
await update.effective_message.reply_markdown_v2(
|
||||
"\n".join(
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue