Browse Source

Заказы работают только с текущими заказами

pull/3/head
Alexei 2 years ago
parent
commit
e0f005f68a
  1. 10
      bot_modules/all_orders.py
  2. 20
      bot_modules/orders.py

10
bot_modules/all_orders.py

@ -25,8 +25,8 @@ button_names.pop(mod_table_operate.ButtonNames.ADD)
cur_button_names = {
mod_simple_message.ButtonNames.START: "🛒 Все заказы",
mod_table_operate.ButtonNames.LIST: "📃 Список всех заказов",
orders.ButtonNames.LIST_CURRENT: "📃 Список текущих заказов",
mod_table_operate.ButtonNames.LIST: "📃 Список текущих заказов",
orders.ButtonNames.LIST_ALL: "📃 Список всех заказов",
mod_table_operate.ButtonNames.EDIT: "🛠 Редактировать заказ",
mod_table_operate.EditButton(bd_table.TableFieldDestiny.PHOTO): "☐ Изменить изображение в заказе",
mod_table_operate.EditButton(bd_table.TableFieldDestiny.NAME): "≂ Изменить название в заказе",
@ -110,11 +110,11 @@ class ModuleAllOrders(orders.ModuleOrders):
def SelectSourceTemplate(self, a_PrevPrefix, a_ButtonName):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName, a_OnlyCurrent = True)
def SelectSourceForCurrentTemplate(self, a_PrevPrefix, a_ButtonName):
def SelectSourceForAllTemplate(self, a_PrevPrefix, a_ButtonName):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName, a_OnlyCurrent = True)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName)
def GetButtonNameAndKeyValueAndAccess(self, a_Item):
parent_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.PARENT_ID)

20
bot_modules/orders.py

@ -51,12 +51,12 @@ init_access = f'{user_access.user_access_group_new}=va'
# Сообщения и кнопки
class ButtonNames(Enum):
LIST_CURRENT = auto()
LIST_ALL = auto()
button_names = {
mod_simple_message.ButtonNames.START: "🛒 Заказы",
mod_table_operate.ButtonNames.LIST: "📃 Список всех моих заказов",
ButtonNames.LIST_CURRENT: "📃 Список моих текущих заказов",
mod_table_operate.ButtonNames.LIST: "📃 Список моих текущих заказов",
ButtonNames.LIST_ALL: "📃 Список всех моих заказов",
mod_table_operate.ButtonNames.ADD: "✅ Добавить заказ",
mod_table_operate.ButtonNames.EDIT: "🛠 Редактировать мой заказ",
mod_table_operate.EditButton(bd_table.TableFieldDestiny.PHOTO_PAY): "☐ Загрузить фото оплаты моего заказа",
@ -195,11 +195,11 @@ class ModuleOrders(mod_table_operate.TableOperateModule):
def SelectSourceTemplate(self, a_PrevPrefix, a_ButtonName):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName, a_OnlyCurrent = True)
def SelectSourceForCurrentTemplate(self, a_PrevPrefix, a_ButtonName):
def SelectSourceForAllTemplate(self, a_PrevPrefix, a_ButtonName):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName, a_OnlyCurrent = True)
return DBItemForUserSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName)
def AddBDItemFunc(self, a_ItemData, a_UserID):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
@ -212,7 +212,7 @@ class ModuleOrders(mod_table_operate.TableOperateModule):
def GetStartKeyboardButtons(self, a_Message, a_UserGroups):
parent_buttons = super().GetStartKeyboardButtons(a_Message, a_UserGroups)
cur_buttons = [
keyboard.ButtonWithAccess(self.GetButton(ButtonNames.LIST_CURRENT), user_access.AccessMode.VIEW, self.GetAccess()),
keyboard.ButtonWithAccess(self.GetButton(ButtonNames.LIST_ALL), user_access.AccessMode.VIEW, self.GetAccess()),
]
return parent_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups)
@ -229,12 +229,12 @@ class ModuleOrders(mod_table_operate.TableOperateModule):
default_keyboard_func = self.m_GetStartKeyboardButtonsFunc
# Список текущих, открытых заказов
a_ButtonName = self.GetButton(ButtonNames.LIST_CURRENT)
# Список всех заказов
a_ButtonName = self.GetButton(ButtonNames.LIST_ALL)
if a_ButtonName:
a_Prefix = self.RegisterSelect(a_ButtonName, user_access.AccessMode.VIEW, only_parent = True)
a_Prefix = bd_item_select.SelectRegisterHandlers(self.m_Bot,\
self.SelectSourceForCurrentTemplate(a_Prefix, a_ButtonName), \
self.SelectSourceForAllTemplate(a_Prefix, a_ButtonName), \
GetButtonNameAndKeyValueAndAccess,\
self.GetMessage(mod_table_operate.Messages.SELECT),\
GetAccess,\

Loading…
Cancel
Save