Browse Source

Правки в заказах #21

1. Кнопка изменить адрес при оповещении
2. <code> сделан построчным
master
parent
commit
efec07bcf0
  1. 8
      bot_modules/all_orders.py
  2. 2
      bot_modules/orders.py
  3. 10
      bot_sys/bd_table.py

8
bot_modules/all_orders.py

@ -153,13 +153,13 @@ class ModuleAllOrders(orders.ModuleOrders):
n, k, a = super().GetButtonNameAndKeyValueAndAccess(a_Item) n, k, a = super().GetButtonNameAndKeyValueAndAccess(a_Item)
return str(a_Item[key_field_id]) + ":" + n + "," + str(a_Item[user_field_id]), k, a 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): def PayInlineKeyboard(a_Message, a_UserGroups):
print('PayInlineKeyboard', a_Message, a_UserGroups, a_ItemID) print('PayInlineKeyboard', a_Message, a_UserGroups, a_ItemID)
cur_buttons = [] cur_buttons = []
orders_mod = self.GetModule(orders.module_name) orders_mod = self.GetModule(orders.module_name)
dst = bd_table.TableFieldDestiny.PHOTO_PAY dst = a_Destiny
if orders_mod: if orders_mod:
prefix = orders_mod.m_EditPrefix.get(dst, None) prefix = orders_mod.m_EditPrefix.get(dst, None)
if prefix: if prefix:
@ -205,7 +205,9 @@ class ModuleAllOrders(orders.ModuleOrders):
inline_keyboard = None inline_keyboard = None
print('new_status', str(orders.OrderStatus.PAY), new_status) print('new_status', str(orders.OrderStatus.PAY), new_status)
if new_status == str(orders.OrderStatus.PAY): 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) await self.SendMessageToUser(msg, owner_id, a_GetInlineButtonsFunc = inline_keyboard)

2
bot_modules/orders.py

@ -134,7 +134,7 @@ messages = {
''', ''',
mod_table_operate.EditMessage(bd_table.TableFieldDestiny.DESC): f''' mod_table_operate.EditMessage(bd_table.TableFieldDestiny.DESC): f'''
Текущее описание заказа: Текущее описание заказа:
#{desc_field} <code>#{desc_field}</code>
Введите новое описание заказа: Введите новое описание заказа:
''', ''',

10
bot_sys/bd_table.py

@ -109,7 +109,9 @@ class Table:
result = a_String result = a_String
for i in range(len(self.m_Fields)): for i in range(len(self.m_Fields)):
f = self.m_Fields[i] f = self.m_Fields[i]
result = result.replace(f'#{f.m_Name}', str(a_BDItem[i])) name = f'#{f.m_Name}'
result = result.replace('<code>' + name + '</code>', '<code>' + str(a_BDItem[i]).replace('\n', '</code>\n<code>') + '</code>')
result = result.replace(name, str(a_BDItem[i]))
return result return result
def ReplaceAllFieldTagsByDict(self, a_String, a_BDItemDict): def ReplaceAllFieldTagsByDict(self, a_String, a_BDItemDict):
@ -168,5 +170,7 @@ def Test():
print(table.GetInitTableRequest()) 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));' 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'] item = [10, 'i2\ni2.1', 'i3', 'i4']
assert table.ReplaceAllFieldTags('#f1 #f2 #f3 #f4', item) == '10 i2 i3 i4' assert table.ReplaceAllFieldTags('#f1 #f2 #f3 #f4', item) == '10 i2\ni2.1 i3 i4'
assert table.ReplaceAllFieldTags('#f1 <code>#f2</code> <code>#f3</code> #f4', item) == '10 <code>i2</code>\n<code>i2.1</code> <code>i3</code> i4', table.ReplaceAllFieldTags('f1 <code>#f2</code> <code>#f3</code> #f4', item)

Loading…
Cancel
Save