Browse Source

Исправлена работа по редактированию элементов и просмотре дочерных проектов

pull/3/head
Alexei 2 years ago
parent
commit
d9cfb97626
  1. 7
      bot_modules/mod_table_operate.py
  2. 3
      template/bd_item_edit.py
  3. 26
      template/bd_item_select.py

7
bot_modules/mod_table_operate.py

@ -250,7 +250,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
def SelectSourceTemplate(self, a_PrevPrefix, a_ButtonName):
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID)
return DBItemSelectSource(self.m_Bot, self.m_TableName.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName)
return bd_item_select.DBItemSelectSource(self.m_Bot, self.m_Table.GetName(), parent_id_field, a_PrevPrefix, a_ButtonName)
def RegisterSelect(self, a_ButtonName, access_mode, only_parent = False):
a_Prefix = None
@ -299,10 +299,10 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
a_ButtonName = self.GetButton(ButtonNames.LIST)
if a_ButtonName:
a_Prefix = self.RegisterSelect(a_ButtonName, user_access.AccessMode.VIEW, only_parent = True)
self.m_SelectPrefix = a_Prefix
a_Prefix = bd_item_select.SelectRegisterHandlers(self.m_Bot,\
self.SelectSourceTemplate(a_Prefix, a_ButtonName), \
a_GetButtonNameAndKeyValueAndAccessFunc,\
GetButtonNameAndKeyValueAndAccess,\
self.GetMessage(Messages.SELECT),\
GetAccess,\
access_mode = user_access.AccessMode.VIEW\
@ -316,7 +316,6 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
defaul_keyboard_func,\
access_mode = user_access.AccessMode.VIEW\
)
self.m_SelectPrefix = a_Prefix
# Удаление
a_ButtonName = self.GetButton(ButtonNames.DEL)

3
template/bd_item_edit.py

@ -35,9 +35,8 @@ def FinishEditBDItemTemplate(a_Bot, a_FSM, a_TableName, a_KeyName, a_FieldName,
def EditBDItemRegisterHandlers(a_Bot, a_SelectSource, a_FSM, a_StartMessage, a_EditMessageFunc, a_FinishMessageFunc, a_TableName : str, a_KeyName, a_FieldName, a_GetButtonNameAndKeyValueAndAccessFunc, a_AccessFunc, a_ButtonFunc, a_OnChangeFunc, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text):
keyboard_cancel = bd_item.GetCancelKeyboardButtonsTemplate(a_Bot, a_AccessFunc, access_mode)
a_Prefix = bd_item.HashPrefix(f'edit_{a_TableName}_{a_KeyName}_{a_FieldName}:')
SelectCustomRegisterHandlers(a_Bot, a_SelectSource, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = access_mode)
a_Prefix = bd_item_select.SelectRegisterHandlers(a_Bot, a_SelectSource, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = access_mode)
a_Bot.RegisterCallbackHandler(StartEditBDItemTemplate(a_Bot, a_FSM, a_EditMessageFunc, a_TableName, a_KeyName, a_Prefix, a_AccessFunc, keyboard_cancel, a_ButtonFunc, access_mode), bd_item.GetCheckForPrefixFunc(a_Prefix))
if field_type == bd_item.FieldType.photo:

26
template/bd_item_select.py

@ -63,30 +63,30 @@ class ISelectSource(ABC):
class DBItemSelectSource:
def __init__(self, a_Bot, a_TableName, a_ParentIDFieldName, a_PrevPrefix, a_ButtonName):
self.a_Bot = a_Bot
self.a_TableName = a_TableName
self.a_ParentIDFieldName = a_ParentIDFieldName
self.a_PrevPrefix = a_PrevPrefix
self.a_ButtonName = a_ButtonName
self.m_Bot = a_Bot
self.m_TableName = a_TableName
self.m_ParentIDFieldName = a_ParentIDFieldName
self.m_PrevPrefix = a_PrevPrefix
self.m_ButtonName = a_ButtonName
def IsFirst(self):
return not self.a_ParentIDFieldName
return not self.m_ParentIDFieldName
def GetItemsFunc(self):
return GetBDItemsTemplate(self.a_Bot, self.a_TableName, self.a_ParentIDFieldName)
return GetBDItemsTemplate(self.m_Bot, self.m_TableName, self.m_ParentIDFieldName)
def GetCheckFunc(self):
if self.IsFirst():
return bd_item.GetCheckForTextFunc(a_ButtonName)
return bd_item.GetCheckForPrefixFunc(a_PrevPrefix)
return bd_item.GetCheckForTextFunc(self.m_ButtonName)
return bd_item.GetCheckForPrefixFunc(self.m_PrevPrefix)
def GetPrevPrefix(self):
return self.a_PrevPrefix
return self.m_PrevPrefix
def GetPrefixBase(self):
if self.a_PrevPrefix:
return self.a_PrevPrefix
return self.a_ButtonName
if self.m_PrevPrefix:
return self.m_PrevPrefix
return self.m_ButtonName
def SelectRegisterHandlers(a_Bot, a_SelectSource, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW):
reg_func = a_Bot.RegisterMessageHandler

Loading…
Cancel
Save