|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
# -*- coding: utf8 -*- |
|
|
|
|
# Общественное достояние, 2023, Алексей Безбородов (Alexei Bezborodov) <AlexeiBv+mirocod_platform_bot@narod.ru> |
|
|
|
|
|
|
|
|
|
# Простой модуль с одним сообщением |
|
|
|
|
# Модуль для редактирования и просмотра таблицы в БД |
|
|
|
|
|
|
|
|
|
from bot_sys import keyboard, user_access |
|
|
|
|
from bot_modules import access_utils, mod_interface |
|
|
|
@ -48,7 +48,6 @@ class FSMs:
|
|
|
|
|
self.m_FSMEditPhoto = a_FSMEditPhoto |
|
|
|
|
self.m_FSMEditAccess = a_FSMEditAccess |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Предназначение поля в таблице |
|
|
|
|
class TableFieldDestiny(Enum): |
|
|
|
|
KEY = auto() |
|
|
|
@ -93,10 +92,10 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def GetButton(self, a_ButtonName): |
|
|
|
|
return self.m_Buttons[a_ButtonName] |
|
|
|
|
return self.m_Buttons.get(a_ButtonName, None) |
|
|
|
|
|
|
|
|
|
def GetMessage(self, a_MessageNames): |
|
|
|
|
return self.m_Messages[a_MessageNames] |
|
|
|
|
return self.m_Messages.get(a_MessageNames, None) |
|
|
|
|
|
|
|
|
|
def GetInitBDCommands(self): |
|
|
|
|
return super(). GetInitBDCommands() + [ |
|
|
|
@ -264,7 +263,9 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Список |
|
|
|
|
a_Prefix = RegisterSelectParent(self.GetButton(ButtonNames.LIST), user_access.AccessMode.VIEW) |
|
|
|
|
a_ButtonName = self.GetButton(ButtonNames.LIST) |
|
|
|
|
if a_ButtonName: |
|
|
|
|
a_Prefix = self.RegisterSelect(a_ButtonName, user_access.AccessMode.VIEW) |
|
|
|
|
bd_item_view.LastSelectAndShowBDItemRegisterHandlers(self.m_Bot, \ |
|
|
|
|
a_Prefix,\ |
|
|
|
|
parent_id_field, \ |
|
|
|
@ -280,7 +281,9 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
self.m_SelectPrefix = a_Prefix |
|
|
|
|
|
|
|
|
|
# Удаление |
|
|
|
|
a_Prefix = RegisterSelectParent(self.GetButton(ButtonNames.DEL), user_access.AccessMode.DELETE) |
|
|
|
|
a_ButtonName = self.GetButton(ButtonNames.DEL) |
|
|
|
|
if a_ButtonName: |
|
|
|
|
a_Prefix = self.RegisterSelect(a_ButtonName, user_access.AccessMode.DELETE) |
|
|
|
|
bd_item_delete.DeleteBDItemRegisterHandlers(self.m_Bot, \ |
|
|
|
|
a_Prefix, \ |
|
|
|
|
bd_item.GetCheckForPrefixFunc(a_Prefix), \ |
|
|
|
@ -296,7 +299,9 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Добавление |
|
|
|
|
a_Prefix = RegisterSelectParent(self.GetButton(ButtonNames.ADD), user_access.AccessMode.ADD) |
|
|
|
|
a_ButtonName = self.GetButton(ButtonNames.ADD) |
|
|
|
|
if a_ButtonName: |
|
|
|
|
a_Prefix = self.RegisterSelect(a_ButtonName, user_access.AccessMode.ADD) |
|
|
|
|
bd_item_add.AddBDItem3RegisterHandlers(self.m_Bot, \ |
|
|
|
|
bd_item.GetCheckForPrefixFunc(a_Prefix), \ |
|
|
|
|
self.m_FSMs.m_FSMCreate, \ |
|
|
|
@ -322,7 +327,9 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
# Редактирование |
|
|
|
|
edit_keyboard_func = self.m_GetEditTaskKeyboardButtonsFunc |
|
|
|
|
def RegisterEdit(a_ButtonName, a_FSM, a_EditMessage, a_FieldName, a_FieldType, a_AccessMode = user_access.AccessMode.EDIT): |
|
|
|
|
a_Prefix = RegisterSelectParent(a_ButtonName, a_AccessMode) |
|
|
|
|
if not a_ButtonName: |
|
|
|
|
return |
|
|
|
|
a_Prefix = self.RegisterSelect(a_ButtonName, a_AccessMode) |
|
|
|
|
bd_item_edit.EditBDItemRegisterHandlers(self.m_Bot, \ |
|
|
|
|
a_Prefix, \ |
|
|
|
|
a_FSM, \ |
|
|
|
@ -341,13 +348,15 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
field_type = a_FieldType\ |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
a_ButtonName = self.GetButton(ButtonNames.EDIT) |
|
|
|
|
if a_ButtonName: |
|
|
|
|
self.m_Bot.RegisterMessageHandler(\ |
|
|
|
|
simple_message.InfoMessageTemplateLegacy(\ |
|
|
|
|
self.GetMessage(Messages.START_EDIT),\ |
|
|
|
|
edit_keyboard_func,\ |
|
|
|
|
GetAccess,\ |
|
|
|
|
access_mode = user_access.AccessMode.EDIT),\ |
|
|
|
|
bd_item.GetCheckForTextFunc(self.GetButton(ButtonNames.EDIT))\ |
|
|
|
|
bd_item.GetCheckForTextFunc(a_ButtonName)\ |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
RegisterEdit(self.GetButton(ButtonNames.EDIT_NAME), self.m_FSMs.m_FSMEditName, self.GetMessage(Messages.EDIT_NAME), name_field, bd_item.FieldType.text) |
|
|
|
|