Browse Source

Задачи можно просматривать. Добавлять пока нельзя.

test_bot
Alexei 2 years ago
parent
commit
76bcb2cf1f
  1. 17
      bot_modules/projects.py
  2. 4
      bot_modules/start.py
  3. 58
      bot_modules/tasks.py
  4. 13
      main.py
  5. 2
      template/bd_item.py
  6. 5
      template/bd_item_add.py
  7. 7
      template/bd_item_select.py
  8. 11
      template/bd_item_view.py

17
bot_modules/projects.py

@ -4,7 +4,7 @@
# Проекты # Проекты
from bot_sys import bot_bd, log, keyboard, user_access from bot_sys import bot_bd, log, keyboard, user_access
from bot_modules import start, access, groups from bot_modules import start, access, groups, tasks
from template import bd_item_view, simple_message, bd_item_delete, bd_item_edit, bd_item, bd_item_add from template import bd_item_view, simple_message, bd_item_delete, bd_item_edit, bd_item, bd_item_add
from aiogram import types from aiogram import types
@ -182,7 +182,7 @@ def GetStartProjectKeyboardButtons(a_Message, a_UserGroups):
keyboard.ButtonWithAccess(del_project_button_name, user_access.AccessMode.DELETE, GetAccess()), keyboard.ButtonWithAccess(del_project_button_name, user_access.AccessMode.DELETE, GetAccess()),
keyboard.ButtonWithAccess(edit_project_button_name, user_access.AccessMode.EDIT, GetAccess()) keyboard.ButtonWithAccess(edit_project_button_name, user_access.AccessMode.EDIT, GetAccess())
] ]
mods = [start] mods = [start, tasks]
return keyboard.MakeKeyboard(keyboard.GetButtons(mods) + cur_buttons, a_UserGroups) return keyboard.MakeKeyboard(keyboard.GetButtons(mods) + cur_buttons, a_UserGroups)
# --------------------------------------------------------- # ---------------------------------------------------------
@ -191,11 +191,12 @@ def GetStartProjectKeyboardButtons(a_Message, a_UserGroups):
select_handler = 0 select_handler = 0
# стартовое сообщение # стартовое сообщение
async def ProjectsOpen(a_Message : types.message, state = None): async def ProjectsOpen(a_Message : types.message, state = None):
user_id = str(a_Message.from_user.id) #user_id = str(a_Message.from_user.id)
user_groups = groups.GetUserGroupData(user_id) #user_groups = groups.GetUserGroupData(user_id)
await a_Message.answer(base_project_message, reply_markup = GetStartProjectKeyboardButtons(a_Message, user_groups)) #await a_Message.answer(base_project_message, reply_markup = GetStartProjectKeyboardButtons(a_Message, user_groups))
await select_handler(a_Message) #await select_handler(a_Message)
return None #return None
return simple_message.WorkFuncResult(base_project_message)
def GetButtonNameAndKeyValueAndAccess(a_Item): def GetButtonNameAndKeyValueAndAccess(a_Item):
# projectName projectID projectAccess # projectName projectID projectAccess
@ -266,7 +267,7 @@ def RegisterHandlers(dp : Dispatcher):
# Список проектов # Список проектов
dp.register_message_handler(simple_message.SimpleMessageTemplate(ProjectsOpen, defaul_keyboard_func, GetAccess), text = projects_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplate(ProjectsOpen, defaul_keyboard_func, GetAccess), text = projects_button_name)
global select_handler global select_handler
select_handler = bd_item_view.SelectAndShowBDItemRegisterHandlers(dp, list_project_button_name, table_name, key_name, ShowMessageTemplate(project_open_message), GetButtonNameAndKeyValueAndAccess, select_project_message, GetAccess, defaul_keyboard_func) select_handler = bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, list_project_button_name, table_name, key_name, ShowMessageTemplate(project_open_message), GetButtonNameAndKeyValueAndAccess, select_project_message, GetAccess, defaul_keyboard_func)
# Удаление проекта # Удаление проекта
bd_item_delete.DeleteBDItemRegisterHandlers(dp, del_project_button_name, table_name, key_name, ProjectPreDelete, ProjectPostDelete, GetButtonNameAndKeyValueAndAccess, select_project_message, GetAccess, defaul_keyboard_func) bd_item_delete.DeleteBDItemRegisterHandlers(dp, del_project_button_name, table_name, key_name, ProjectPreDelete, ProjectPostDelete, GetButtonNameAndKeyValueAndAccess, select_project_message, GetAccess, defaul_keyboard_func)

4
bot_modules/start.py

@ -4,7 +4,7 @@
# Стартовое меню # Стартовое меню
from bot_sys import log, config, keyboard, user_access from bot_sys import log, config, keyboard, user_access
from bot_modules import profile, projects, groups, access, backup from bot_modules import profile, projects, groups, access, backup, tasks
from template import simple_message from template import simple_message
from aiogram.dispatcher import Dispatcher from aiogram.dispatcher import Dispatcher
@ -31,7 +31,7 @@ start_menu_button_name = "☰ Главное меню"
# Работа с кнопками # Работа с кнопками
def GetStartKeyboardButtons(a_Message, a_UserGroups): def GetStartKeyboardButtons(a_Message, a_UserGroups):
mods = [profile, projects, groups, access, backup] mods = [profile, projects, groups, access, backup, tasks]
return keyboard.MakeKeyboardForMods(mods, a_UserGroups) return keyboard.MakeKeyboardForMods(mods, a_UserGroups)
# --------------------------------------------------------- # ---------------------------------------------------------

58
bot_modules/tasks.py

@ -4,8 +4,8 @@
# Задачи # Задачи
from bot_sys import bot_bd, log, keyboard, user_access from bot_sys import bot_bd, log, keyboard, user_access
from bot_modules import start, access, groups from bot_modules import start, access, groups, projects
from template import bd_item_view, simple_message, bd_item_delete, bd_item_edit, bd_item, bd_item_add from template import bd_item_view, simple_message, bd_item_delete, bd_item_edit, bd_item, bd_item_add, bd_item_select
from aiogram import types from aiogram import types
@ -53,7 +53,7 @@ init_bd_cmds = [f'''CREATE TABLE IF NOT EXISTS {table_name}(
{desc_field} TEXT, {desc_field} TEXT,
{photo_field} TEXT, {photo_field} TEXT,
{access_field} TEXT, {access_field} TEXT,
{create_datetime_field} TEXT {create_datetime_field} TEXT,
{parent_id_field} INTEGER {parent_id_field} INTEGER
)''', )''',
f"INSERT OR IGNORE INTO module_access (modName, modAccess, itemDefaultAccess) VALUES ('{module_name}', '{user_access.user_access_group_new}=va', '{user_access.user_access_group_new}=va');" f"INSERT OR IGNORE INTO module_access (modName, modAccess, itemDefaultAccess) VALUES ('{module_name}', '{user_access.user_access_group_new}=va', '{user_access.user_access_group_new}=va');"
@ -62,9 +62,9 @@ f"INSERT OR IGNORE INTO module_access (modName, modAccess, itemDefaultAccess) VA
# --------------------------------------------------------- # ---------------------------------------------------------
# Сообщения # Сообщения
tasks_button_name = "🟥 Задачи" tasks_button_name = " Задачи"
base_task_message = ''' base_task_message = '''
<b>🟥 Задачи</b> <b> Задачи</b>
''' '''
@ -262,40 +262,46 @@ def GetModuleButtons():
# Обработка кнопок # Обработка кнопок
def RegisterHandlers(dp : Dispatcher): def RegisterHandlers(dp : Dispatcher):
defaul_keyboard_func = GetStartTaskKeyboardButtons defaul_keyboard_func = GetStartTaskKeyboardButtons
# Стартовое сообщение # Стартовое сообщение
dp.register_message_handler(simple_message.SimpleMessageTemplate(TasksOpen, defaul_keyboard_func, GetAccess), text = tasks_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplate(TasksOpen, defaul_keyboard_func, GetAccess), text = tasks_button_name)
# Список задач projects.
a_Prefix, sel_handler = bd_item_select.FirstSelectBDItemRegisterHandlers(dp, 'view_task', list_task_button_name, projects.table_name, projects.key_name, projects.GetButtonNameAndKeyValueAndAccess, projects.select_project_message, projects.GetAccess, access_mode = user_access.AccessMode.VIEW)
bd_item_view.LastSelectAndShowBDItemRegisterHandlers(dp, a_Prefix, parent_id_field, table_name, key_name, ShowMessageTemplate(task_open_message), GetButtonNameAndKeyValueAndAccess, select_task_message, GetAccess, defaul_keyboard_func, access_mode = user_access.AccessMode.VIEW)
# Список задач '''
select_handler = bd_item_view.SelectAndShowBDItemRegisterHandlers(dp, list_task_button_name, table_name, key_name, ShowMessageTemplate(task_open_message), GetButtonNameAndKeyValueAndAccess, select_task_message, GetAccess, defaul_keyboard_func)
# Удаление задачи # Удаление задачи
bd_item_delete.DeleteBDItemRegisterHandlers(dp, del_task_button_name, table_name, key_name, TaskPreDelete, TaskPostDelete, GetButtonNameAndKeyValueAndAccess, select_task_message, GetAccess, defaul_keyboard_func) # a_Prefix, sel_handler = bd_item_select.FirstSelectBDItemRegisterHandlers(dp, 'del_task', add_task_button_name, projects.table_name, projects.key_name, projects.GetButtonNameAndKeyValueAndAccess, projects.select_project_message, projects.GetAccess, access_mode = user_access.AccessMode.VIEW)
# bd_item_delete.DeleteBDItemRegisterHandlers(dp, del_task_button_name, table_name, key_name, TaskPreDelete, TaskPostDelete, GetButtonNameAndKeyValueAndAccess, select_task_message, GetAccess, defaul_keyboard_func)
'''
# Добавление задачи # Добавление задачи
a_Prefix, sel_handler = bd_item_select.FirstSelectBDItemRegisterHandlers(dp, 'add_task', add_task_button_name, projects.table_name, projects.key_name, projects.GetButtonNameAndKeyValueAndAccess, projects.select_project_message, projects.GetAccess, access_mode = user_access.AccessMode.VIEW)
bd_item_add.AddBDItem3RegisterHandlers(dp, \ bd_item_add.AddBDItem3RegisterHandlers(dp, \
bd_item.GetCheckForTextFunc(add_project_button_name), \ bd_item.GetCheckForPrefixFunc(a_Prefix), \
FSMCreateProject, FSMCreateProject.name,\ FSMCreateTask, \
FSMCreateProject.desc, FSMCreateProject.photo,\ FSMCreateTask.name,\
AddBDItemFunc, SimpleMessageTemplate(project_create_name_message), \ FSMCreateTask.desc, \
SimpleMessageTemplate(project_create_desc_message), \ FSMCreateTask.photo,\
SimpleMessageTemplate(project_create_photo_message), \ AddBDItemFunc, \
SimpleMessageTemplate(project_success_create_message), \ SimpleMessageTemplate(task_create_name_message), \
None, \ SimpleMessageTemplate(task_create_desc_message), \
None, \ SimpleMessageTemplate(task_create_photo_message), \
SimpleMessageTemplate(task_success_create_message), \
projects.table_name, \
projects.key_name, \
name_field, \ name_field, \
desc_field, \ desc_field, \
photo_field, \ photo_field, \
GetButtonNameAndKeyValueAndAccess, \ GetButtonNameAndKeyValueAndAccess, \
GetAccess, \ GetAccess, \
GetStartProjectKeyboardButtons\ GetStartTaskKeyboardButtons\
) )
edit_keyboard_func = GetEditTaskKeyboardButtons
# Редактирование задачи # Редактирование задачи
dp.register_message_handler(simple_message.InfoMessageTemplate(task_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_task_button_name) # edit_keyboard_func = GetEditTaskKeyboardButtons
bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditPhotoItem, edit_task_photo_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_photo_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, photo_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.photo) # dp.register_message_handler(simple_message.InfoMessageTemplate(task_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_task_button_name)
bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditNameItem, edit_task_name_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_name_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, name_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text) # bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditPhotoItem, edit_task_photo_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_photo_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, photo_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.photo)
bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditDeskItem, edit_task_desc_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_desc_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, desc_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text) # bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditNameItem, edit_task_name_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_name_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, name_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text)
bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditAccessItem, edit_task_access_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_access_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, access_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.ACCEES_EDIT, field_type = bd_item.FieldType.text) # bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditDeskItem, edit_task_desc_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_desc_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, desc_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text)
# bd_item_edit.EditBDItemRegisterHandlers(dp, FSMEditAccessItem, edit_task_access_button_name, task_select_to_edit_message, ShowMessageTemplate(task_edit_access_message), ShowMessageTemplate(task_success_edit_message), table_name, key_name, access_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.ACCEES_EDIT, field_type = bd_item.FieldType.text)

13
main.py

@ -10,28 +10,29 @@ from aiogram.dispatcher import Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage from aiogram.contrib.fsm_storage.memory import MemoryStorage
import sqlite3 import sqlite3
from bot_sys import config, log, bot_bd, user_access from bot_sys import config, log, bot_bd, user_access
from bot_modules import profile, start, projects, groups, access, backup from bot_modules import profile, start, projects, groups, access, backup, tasks
storage = MemoryStorage() storage = MemoryStorage()
bot = Bot(token=config.GetTelegramBotApiToken(), parse_mode = types.ParseMode.HTML) bot = Bot(token=config.GetTelegramBotApiToken(), parse_mode = types.ParseMode.HTML)
dp = Dispatcher(bot, storage = storage) dp = Dispatcher(bot, storage = storage)
mods = [access, profile, start, projects, groups, backup] # Первичная инициализация модулей. Все модули должны быть прописаны в списке modules
modules = [tasks, access, profile, start, projects, groups, backup, ]
init_bd_cmd = [] init_bd_cmd = []
for m in mods: for m in modules:
m.RegisterHandlers(dp) m.RegisterHandlers(dp)
c = m.GetInitBDCommands() c = m.GetInitBDCommands()
if not c is None: if not c is None:
init_bd_cmd += c init_bd_cmd += c
# Первичаня инициализация базы данных
bot_bd.BDExecute(init_bd_cmd)
# Юнит тесты модулей и файлов
test_mods = [user_access] test_mods = [user_access]
for m in test_mods: for m in test_mods:
m.Test() m.Test()
# Первичаня инициализация базы данных
bot_bd.BDExecute(init_bd_cmd)
if __name__ == '__main__': if __name__ == '__main__':
os.system('clear') os.system('clear')
os.system('cls') os.system('cls')

2
template/bd_item.py

@ -35,7 +35,7 @@ def GetCheckForTextFunc(a_Text):
def GetKeyDataFromCallbackMessage(a_Message, a_Prefix): def GetKeyDataFromCallbackMessage(a_Message, a_Prefix):
key_item_id = None key_item_id = None
if hasattr(a_Message, 'data'): if hasattr(a_Message, 'data'):
key_item_id = str(a_Message.data).replace(a_PrevPrefix, '') key_item_id = str(a_Message.data).replace(a_Prefix, '')
return key_item_id return key_item_id
def GetCancelKeyboardButtonsTemplate(a_AccessFunc, a_AccessMode): def GetCancelKeyboardButtonsTemplate(a_AccessFunc, a_AccessMode):

5
template/bd_item_add.py

@ -102,7 +102,10 @@ def AddBDItem3RegisterHandlers(dp, a_StartCheckFunc, a_FSM, a_FSMName, a_FSMDesc
keyboard_cancel = bd_item.GetCancelKeyboardButtonsTemplate(a_AccessFunc, access_mode) keyboard_cancel = bd_item.GetCancelKeyboardButtonsTemplate(a_AccessFunc, access_mode)
keyboard_skip_and_cancel = bd_item.GetSkipAndCancelKeyboardButtonsTemplate(a_AccessFunc, access_mode) keyboard_skip_and_cancel = bd_item.GetSkipAndCancelKeyboardButtonsTemplate(a_AccessFunc, access_mode)
a_Prefix = f'add_{a_ParentTableName}_{a_ParentKeyFieldName}_{a_NameField}_{a_DescField}_{a_PhotoField}:' a_Prefix = f'add_{a_ParentTableName}_{a_ParentKeyFieldName}_{a_NameField}_{a_DescField}_{a_PhotoField}:'
dp.register_message_handler(StartAddBDItemTemplate(a_FSM, a_FSMName, a_AddNameMessageFunc, a_ParentTableName, a_ParentKeyFieldName, a_Prefix, a_AccessFunc, keyboard_cancel, a_ButtonFunc, access_mode), a_StartCheckFunc) if a_ParentTableName:
dp.register_callback_query_handler(StartAddBDItemTemplate(a_FSM, a_FSMName, a_AddNameMessageFunc, a_ParentTableName, a_ParentKeyFieldName, a_Prefix, a_AccessFunc, keyboard_cancel, a_ButtonFunc, access_mode), a_StartCheckFunc)
else:
dp.register_message_handler(StartAddBDItemTemplate(a_FSM, a_FSMName, a_AddNameMessageFunc, a_ParentTableName, a_ParentKeyFieldName, a_Prefix, a_AccessFunc, keyboard_cancel, a_ButtonFunc, access_mode), a_StartCheckFunc)
dp.register_message_handler(NextAddBDItemTemplate(a_FSM, None, a_ParentTableName, a_ParentKeyFieldName, a_NameField, a_AddDescMessageFunc, a_AccessFunc, keyboard_cancel, a_ButtonFunc, access_mode, field_type = bd_item.FieldType.text), state = a_FSMName) dp.register_message_handler(NextAddBDItemTemplate(a_FSM, None, a_ParentTableName, a_ParentKeyFieldName, a_NameField, a_AddDescMessageFunc, a_AccessFunc, keyboard_cancel, a_ButtonFunc, access_mode, field_type = bd_item.FieldType.text), state = a_FSMName)
dp.register_message_handler(NextAddBDItemTemplate(a_FSM, None, a_ParentTableName, a_ParentKeyFieldName, a_DescField, a_AddPhotoMessageFunc, a_AccessFunc, keyboard_skip_and_cancel, a_ButtonFunc, access_mode, field_type = bd_item.FieldType.text), state = a_FSMDesc) dp.register_message_handler(NextAddBDItemTemplate(a_FSM, None, a_ParentTableName, a_ParentKeyFieldName, a_DescField, a_AddPhotoMessageFunc, a_AccessFunc, keyboard_skip_and_cancel, a_ButtonFunc, access_mode, field_type = bd_item.FieldType.text), state = a_FSMDesc)
dp.register_message_handler(FinishAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, a_PhotoField, a_FinishMessageFunc, a_AccessFunc, a_ButtonFunc, a_ButtonFunc, access_mode, field_type = bd_item.FieldType.photo), content_types = ['photo', 'text'], state = a_FSMPhoto) dp.register_message_handler(FinishAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, a_PhotoField, a_FinishMessageFunc, a_AccessFunc, a_ButtonFunc, a_ButtonFunc, access_mode, field_type = bd_item.FieldType.photo), content_types = ['photo', 'text'], state = a_FSMPhoto)

7
template/bd_item_select.py

@ -33,8 +33,9 @@ def SelectDBItemTemplate(a_TableName : str, a_ParentIDFieldName, a_GetButtonName
return simple_message.InfoMessageTemplate(a_StartMessage, keyborad_func, a_AccessFunc, access_mode) return simple_message.InfoMessageTemplate(a_StartMessage, keyborad_func, a_AccessFunc, access_mode)
def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW):
a_Prefix = f'{a_PrefixBase}select_{a_TableName}_{a_KeyName}:' a_Prefix = f'{a_PrefixBase}select_{a_TableName}_{a_KeyName}:'
sel_handler = bd_item_select.SelectDBItemTemplate(a_TableName, None, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, None, a_Prefix, access_mode = access_mode) sel_handler = SelectDBItemTemplate(a_TableName, None, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, None, a_Prefix, access_mode = access_mode)
dp.register_message_handler(sel_handler, text = a_ButtonName) dp.register_message_handler(sel_handler, text = a_ButtonName)
return a_Prefix, sel_handler return a_Prefix, sel_handler
@ -42,7 +43,7 @@ def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableNam
def NextSelectBDItemRegisterHandlers(dp, a_PrevPrefix, a_ParentIDFieldName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): def NextSelectBDItemRegisterHandlers(dp, a_PrevPrefix, a_ParentIDFieldName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW):
a_Prefix = f'{a_PrevPrefix}_select_{a_TableName}_{a_KeyName}_{a_ParentIDFieldName}:' a_Prefix = f'{a_PrevPrefix}_select_{a_TableName}_{a_KeyName}_{a_ParentIDFieldName}:'
sel_handler = bd_item_select.SelectDBItemTemplate(a_TableName, a_ParentIDFieldName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_PrevPrefix, a_Prefix, access_mode = access_mode) sel_handler = SelectDBItemTemplate(a_TableName, a_ParentIDFieldName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_PrevPrefix, a_Prefix, access_mode = access_mode)
dp.register_message_handler(sel_handler, bd_iem.GetCheckForPrefixFunc(a_PrevPrefix)) dp.register_callback_query_handler(sel_handler, bd_item.GetCheckForPrefixFunc(a_PrevPrefix))
return a_Prefix, sel_handler return a_Prefix, sel_handler

11
template/bd_item_view.py

@ -15,10 +15,11 @@ def ShowBDItemTemplate(a_TableName, a_KeyName, a_WorkFunc, a_Prefix, a_AccessFun
def ShowBDItemRegisterHandlers(dp, a_PrevPrefix, a_TableName : str, a_KeyName, a_ShowItemWorkFunc, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.VIEW): def ShowBDItemRegisterHandlers(dp, a_PrevPrefix, a_TableName : str, a_KeyName, a_ShowItemWorkFunc, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.VIEW):
dp.register_callback_query_handler(ShowBDItemTemplate(a_TableName, a_KeyName, a_ShowItemWorkFunc, a_PrevPrefix, a_AccessFunc, a_ButtonFunc, access_mode = access_mode), bd_item.GetCheckForPrefixFunc(a_PrevPrefix)) dp.register_callback_query_handler(ShowBDItemTemplate(a_TableName, a_KeyName, a_ShowItemWorkFunc, a_PrevPrefix, a_AccessFunc, a_ButtonFunc, access_mode = access_mode), bd_item.GetCheckForPrefixFunc(a_PrevPrefix))
def SelectAndShowBDItemRegisterHandlers(dp, a_ButtonName, a_TableName : str, a_KeyName, a_ShowItemWorkFunc, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.VIEW): def FirstSelectAndShowBDItemRegisterHandlers(dp, a_ButtonName, a_TableName : str, a_KeyName, a_ShowItemWorkFunc, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.VIEW):
a_Prefix = f'select_{a_TableName}_{a_KeyName}:' a_Prefix, sel_handler = bd_item_select.FirstSelectBDItemRegisterHandlers(dp, '', a_ButtonName, a_TableName, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = access_mode)
sel_handler = bd_item_select.SelectDBItemTemplate(a_TableName, None, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, None, a_Prefix, access_mode = access_mode)
dp.register_message_handler(sel_handler, text = a_ButtonName)
ShowBDItemRegisterHandlers(dp, a_Prefix, a_TableName, a_KeyName, a_ShowItemWorkFunc, a_AccessFunc, a_ButtonFunc, access_mode = access_mode) ShowBDItemRegisterHandlers(dp, a_Prefix, a_TableName, a_KeyName, a_ShowItemWorkFunc, a_AccessFunc, a_ButtonFunc, access_mode = access_mode)
return sel_handler return sel_handler
def LastSelectAndShowBDItemRegisterHandlers(dp, a_PrevPrefix, a_ParentIDFieldName, a_TableName : str, a_KeyName, a_ShowItemWorkFunc, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.VIEW):
a_Prefix, sel_handler = bd_item_select.NextSelectBDItemRegisterHandlers(dp, a_PrevPrefix, a_ParentIDFieldName, a_TableName, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = access_mode)
ShowBDItemRegisterHandlers(dp, a_Prefix, a_TableName, a_KeyName, a_ShowItemWorkFunc, a_AccessFunc, a_ButtonFunc, access_mode = access_mode)

Loading…
Cancel
Save