Browse Source

Упрощение заказов #22

1. Убраны названия и фото
2. Добавлена кнока "добавить заказ" на главную
master
parent
commit
0eed251ba3
  1. 9
      bot_modules/all_orders.py
  2. 9
      bot_modules/mod_table_operate.py
  3. 30
      bot_modules/orders.py

9
bot_modules/all_orders.py

@ -150,13 +150,12 @@ class ModuleAllOrders(orders.ModuleOrders):
def GetButtonNameAndKeyValueAndAccess(self, a_Item):
user_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_ID)
key_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.KEY)
n, k, a = super().GetButtonNameAndKeyValueAndAccess(a_Item)
return str(a_Item[key_field_id]) + ":" + n + "," + str(a_Item[user_field_id]), k, a
return n + "," + str(a_Item[user_field_id]), k, a
def GetPayInlineKeyboardFunc(self, a_ItemID, a_Destiny):
def PayInlineKeyboard(a_Message, a_UserGroups):
print('PayInlineKeyboard', a_Message, a_UserGroups, a_ItemID)
#print('PayInlineKeyboard', a_Message, a_UserGroups, a_ItemID)
cur_buttons = []
orders_mod = self.GetModule(orders.module_name)
@ -169,7 +168,7 @@ class ModuleAllOrders(orders.ModuleOrders):
keyboard.InlineButtonWithAccess(orders_mod.GetButton(mod_table_operate.EditButton(dst)), prefix, a_ItemID, orders_mod.GetAccess(), access),
]
print('cur_buttons', cur_buttons, a_Message, a_UserGroups, a_ItemID)
#print('cur_buttons', cur_buttons, a_Message, a_UserGroups, a_ItemID)
return keyboard.MakeInlineKeyboardButtons(self.m_Bot, cur_buttons, a_UserGroups)
return PayInlineKeyboard
@ -204,7 +203,7 @@ class ModuleAllOrders(orders.ModuleOrders):
return
msg = self.UpdateMessage(msg, None, item)
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):
inline_keyboard = self.GetPayInlineKeyboardFunc(a_ItemID, bd_table.TableFieldDestiny.PHOTO_PAY)
elif new_status == str(orders.OrderStatus.ADDRESS):

9
bot_modules/mod_table_operate.py

@ -467,7 +467,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
key_name = self.GetKeyFieldName()
cur_item = GetCurItem(self.m_Bot, table_name, key_name, a_ItemID)
print(cur_item)
#print(cur_item)
parent_id_field_index = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
if parent_id_field_index and cur_item and cur_item[parent_id_field_index]:
@ -520,8 +520,8 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
self.m_EditPrefix.update({a_Field.m_Destiny: a_Prefix})
def GetAddFields(self):
add_destiny = (
def GetAddFieldDestinys(self):
return (
bd_table.TableFieldDestiny.NAME,
bd_table.TableFieldDestiny.DESC,
bd_table.TableFieldDestiny.PHOTO,
@ -535,6 +535,9 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
bd_table.TableFieldDestiny.USER_CONTACTS,
bd_table.TableFieldDestiny.USER_CONFIRM,
)
def GetAddFields(self):
add_destiny = self.GetAddFieldDestinys()
fields = []
for f in self.m_Table.GetFields():
if f.m_Destiny in add_destiny:

30
bot_modules/orders.py

@ -232,12 +232,42 @@ class ModuleOrders(mod_table_operate.TableOperateModule):
def AddBDItemFunc(self, a_ItemData, a_UserID):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
a_ItemData[name_field] = ''
a_ItemData[photo_field] = ''
a_ItemData[user_id_field] = a_UserID
a_ItemData[status_field] = str(OrderStatus.NEW)
a_ItemData[address_field] = ''
a_ItemData[photo_pay_field] = '0'
return super().AddBDItemFunc(a_ItemData, a_UserID)
def GetModuleButtons(self):
buttons = super().GetModuleButtons();
add_order_button = [
keyboard.ButtonWithAccess(self.GetButton(mod_table_operate.ButtonNames.ADD), user_access.AccessMode.ADD, self.GetAccess()),
]
return add_order_button + buttons
def GetNameFromDesc(self, a_Desc):
name = ''
lines = str(a_Desc).splitlines()
for l in lines:
name = l.strip();
if len(name) > 0:
break;
return name[0:16]
def GetButtonNameAndKeyValueAndAccess(self, a_Item):
user_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_ID)
key_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.KEY)
desc_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.DESC)
n, k, a = super().GetButtonNameAndKeyValueAndAccess(a_Item)
return str(a_Item[key_field_id]) + ":" + str(self.GetNameFromDesc(a_Item[desc_field_id])), k, a
def GetAddFieldDestinys(self):
return (
bd_table.TableFieldDestiny.DESC,
)
def GetStartButtons(self, a_Message, a_UserGroups):
pay_access = self.GetAccessForEditKeyboardButtons(pay_field)
return [

Loading…
Cancel
Save