add tmc element
This commit is contained in:
parent
25237f11ed
commit
979c19e67f
|
@ -140,11 +140,12 @@ class TgBot:
|
|||
|
||||
tmc_id = query.data.split("@")[-1]
|
||||
tmc = await CustomTable.objects.aget(id=tmc_id)
|
||||
tmc_element = await TmcElement.objects.acreate(tmc=tmc)
|
||||
inv = await TgItem.objects.aget(id=context.chat_data["inv"])
|
||||
|
||||
await inv.tmc.aadd(tmc)
|
||||
await inv.tmc.aadd(tmc_element)
|
||||
|
||||
context.chat_data["tmc"] = tmc.id
|
||||
context.chat_data["tmc"] = tmc_element.id
|
||||
context.chat_data["step"] = "add_tmc"
|
||||
|
||||
await self.inv(update, context)
|
||||
|
@ -229,15 +230,17 @@ class TgBot:
|
|||
|
||||
elif current_step == "add_tmc":
|
||||
inv = await TgItem.objects.aget(id=context.chat_data["inv"])
|
||||
tmc = await CustomTable.objects.aget(id=context.chat_data["tmc"])
|
||||
await inv.tmc.aadd(tmc)
|
||||
tmc_element = await inv.tmc.aget(id=context.chat_data["tmc"])
|
||||
logger.info(tmc_element)
|
||||
tmc = await CustomTable.objects.aget(id=tmc_element.tmc_id)
|
||||
logger.info(tmc)
|
||||
|
||||
fields = []
|
||||
async for e in tmc.fields.all():
|
||||
fields.append({"name": e.name, "id": e.id})
|
||||
keys = chunk(1, fields)
|
||||
|
||||
context.chat_data["tmc"] = tmc.id
|
||||
context.chat_data["tmc"] = tmc_element.id
|
||||
context.chat_data["step"] = "add_element"
|
||||
|
||||
await update.effective_message.reply_markdown_v2(
|
||||
|
@ -342,6 +345,5 @@ class TgBot:
|
|||
f"<pre>context.user_data = {html.escape(str(context.user_data))}</pre>\n\n"
|
||||
f"<pre>{html.escape(tb_string)}</pre>"
|
||||
)
|
||||
logger.error(context.error)
|
||||
# logger.error(context.error)
|
||||
logger.info(f"error in tgbot {context.error}\nReply update")
|
||||
TgBotUpdater.my_queue.put(update)
|
||||
|
|
Loading…
Reference in New Issue