From efec07bcf0ae0f142755904be6e8d55db1edcc6b Mon Sep 17 00:00:00 2001 From: Alexei Bezborodov Date: Wed, 29 Nov 2023 20:34:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0=D1=85=20#21=201.=20?= =?UTF-8?q?=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=82=D1=8C=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BE=D0=BF=D0=BE=D0=B2=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8=202.=20=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=20=D0=BF=D0=BE=D1=81=D1=82=D1=80=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D1=8B=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot_modules/all_orders.py | 10 ++++++---- bot_modules/orders.py | 2 +- bot_sys/bd_table.py | 10 +++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bot_modules/all_orders.py b/bot_modules/all_orders.py index 7fbf33c..b56bd0b 100644 --- a/bot_modules/all_orders.py +++ b/bot_modules/all_orders.py @@ -153,13 +153,13 @@ class ModuleAllOrders(orders.ModuleOrders): n, k, a = super().GetButtonNameAndKeyValueAndAccess(a_Item) return str(a_Item[key_field_id]) + ":" + n + "," + str(a_Item[user_field_id]), k, a - def GetPayInlineKeyboardFunc(self, a_ItemID): + def GetPayInlineKeyboardFunc(self, a_ItemID, a_Destiny): def PayInlineKeyboard(a_Message, a_UserGroups): print('PayInlineKeyboard', a_Message, a_UserGroups, a_ItemID) cur_buttons = [] orders_mod = self.GetModule(orders.module_name) - dst = bd_table.TableFieldDestiny.PHOTO_PAY + dst = a_Destiny if orders_mod: prefix = orders_mod.m_EditPrefix.get(dst, None) if prefix: @@ -205,8 +205,10 @@ class ModuleAllOrders(orders.ModuleOrders): inline_keyboard = None print('new_status', str(orders.OrderStatus.PAY), new_status) if new_status == str(orders.OrderStatus.PAY): - inline_keyboard = self.GetPayInlineKeyboardFunc(a_ItemID) - + inline_keyboard = self.GetPayInlineKeyboardFunc(a_ItemID, bd_table.TableFieldDestiny.PHOTO_PAY) + elif new_status == str(orders.OrderStatus.ADDRESS): + inline_keyboard = self.GetPayInlineKeyboardFunc(a_ItemID, bd_table.TableFieldDestiny.ADDRESS) + await self.SendMessageToUser(msg, owner_id, a_GetInlineButtonsFunc = inline_keyboard) def GetStartButtons(self, a_Message, a_UserGroups): diff --git a/bot_modules/orders.py b/bot_modules/orders.py index 41fd866..745ab5c 100644 --- a/bot_modules/orders.py +++ b/bot_modules/orders.py @@ -134,7 +134,7 @@ messages = { ''', mod_table_operate.EditMessage(bd_table.TableFieldDestiny.DESC): f''' Текущее описание заказа: -#{desc_field} +#{desc_field} Введите новое описание заказа: ''', diff --git a/bot_sys/bd_table.py b/bot_sys/bd_table.py index 25c2981..ef523b7 100644 --- a/bot_sys/bd_table.py +++ b/bot_sys/bd_table.py @@ -109,7 +109,9 @@ class Table: result = a_String for i in range(len(self.m_Fields)): f = self.m_Fields[i] - result = result.replace(f'#{f.m_Name}', str(a_BDItem[i])) + name = f'#{f.m_Name}' + result = result.replace('' + name + '', '' + str(a_BDItem[i]).replace('\n', '\n') + '') + result = result.replace(name, str(a_BDItem[i])) return result def ReplaceAllFieldTagsByDict(self, a_String, a_BDItemDict): @@ -168,5 +170,7 @@ def Test(): print(table.GetInitTableRequest()) assert table.GetInitTableRequest() == 'CREATE TABLE IF NOT EXISTS tname(f1 INTEGER PRIMARY KEY, f2 TEXT, f3 TEXT, f4 TEXT, UNIQUE(f1), UNIQUE(f2, f3));' - item = [10, 'i2', 'i3', 'i4'] - assert table.ReplaceAllFieldTags('#f1 #f2 #f3 #f4', item) == '10 i2 i3 i4' + item = [10, 'i2\ni2.1', 'i3', 'i4'] + assert table.ReplaceAllFieldTags('#f1 #f2 #f3 #f4', item) == '10 i2\ni2.1 i3 i4' + + assert table.ReplaceAllFieldTags('#f1 #f2 #f3 #f4', item) == '10 i2\ni2.1 i3 i4', table.ReplaceAllFieldTags('f1 #f2 #f3 #f4', item)