Browse Source

Исправлено редактирование проектов

test_bot
Alexei 2 years ago
parent
commit
d31bfc0470
  1. 22
      bot_modules/access.py
  2. 8
      bot_modules/comments.py
  3. 16
      bot_modules/needs.py
  4. 72
      bot_modules/projects.py
  5. 16
      bot_modules/tasks.py

22
bot_modules/access.py

@ -184,5 +184,23 @@ def RegisterHandlers(dp : Dispatcher):
sql_request.RequestToBDRegisterHandlers(dp, sql_request_button_name, request_start_message, FSMRequestToBDAccess, defaul_keyboard_func, user_access.AccessMode.ACCEES_EDIT, GetAccess)
edit_keyboard_func = defaul_keyboard_func
bd_item_edit.EditBDItemRegisterHandlers(dp, None, FSMEditAccessItem, bd_item.GetCheckForTextFunc(edit_moduleaccess_access_button_name), moduleaccess_select_to_edit_message, ShowMessageTemplate(moduleaccess_edit_access_message), ShowMessageTemplate(moduleaccess_success_edit_message), table_name, mod_name_field, None, moduleaccess_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.ACCEES_EDIT, field_type = bd_item.FieldType.text)
bd_item_edit.EditBDItemRegisterHandlers(dp, None, FSMEditDefaultAccessItem, bd_item.GetCheckForTextFunc(edit_moduleaccess_default_access_button_name), moduleaccess_select_to_edit_message, ShowMessageTemplate(moduleaccess_edit_default_access_message), ShowMessageTemplate(moduleaccess_success_edit_message), table_name, mod_name_field, None, mod_default_access_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.ACCEES_EDIT, field_type = bd_item.FieldType.text)
def RegisterEdit(a_ButtonName, a_FSM, a_EditMessage, a_FieldName, a_FieldType, a_AccessMode = user_access.AccessMode.ACCEES_EDIT):
bd_item_edit.EditBDItemRegisterHandlers(dp, \
None, \
a_FSM, \
bd_item.GetCheckForTextFunc(a_ButtonName), \
moduleaccess_select_to_edit_message, \
ShowMessageTemplate(a_EditMessage), \
ShowMessageTemplate(moduleaccess_success_edit_message), \
table_name, \
mod_name_field, \
None, \
a_FieldName, \
GetButtonNameAndKeyValueAndAccess, \
GetAccess, \
edit_keyboard_func, \
access_mode = a_AccessMode, \
field_type = a_FieldType\
)
RegisterEdit(edit_moduleaccess_access_button_name, FSMEditAccessItem, moduleaccess_edit_access_message, moduleaccess_field, bd_item.FieldType.text, user_access.AccessMode.ACCEES_EDIT)
RegisterEdit(edit_moduleaccess_default_access_button_name, FSMEditDefaultAccessItem, moduleaccess_edit_default_access_message, mod_default_access_field, bd_item.FieldType.text, user_access.AccessMode.EDIT)

8
bot_modules/comments.py

@ -17,11 +17,11 @@ import sqlite3
class FSMCreateComment(StatesGroup):
bd_item = State()
class FSMEditDescItem(StatesGroup):
class FSMEditCommentDescItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditAccessItem(StatesGroup):
class FSMEditCommentAccessItem(StatesGroup):
item_id = State()
item_field = State()
# ---------------------------------------------------------
@ -327,5 +327,5 @@ def RegisterHandlers(dp : Dispatcher):
edit_keyboard_func = GetEditCommentKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(comment_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_comment_button_name)
RegisterEdit(edit_comment_desc_button_name, FSMEditDescItem, comment_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_comment_access_button_name, FSMEditAccessItem, comment_edit_access_message, access_field, bd_item.FieldType.text)
RegisterEdit(edit_comment_desc_button_name, FSMEditCommentDescItem, comment_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_comment_access_button_name, FSMEditCommentAccessItem, comment_edit_access_message, access_field, bd_item.FieldType.text)

16
bot_modules/needs.py

@ -19,19 +19,19 @@ class FSMCreateNeed(StatesGroup):
desc = State()
photo = State()
class FSMEditPhotoItem(StatesGroup):
class FSMEditNeedPhotoItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditNameItem(StatesGroup):
class FSMEditNeedNameItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditDescItem(StatesGroup):
class FSMEditNeedDescItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditAccessItem(StatesGroup):
class FSMEditNeedAccessItem(StatesGroup):
item_id = State()
item_field = State()
# ---------------------------------------------------------
@ -380,7 +380,7 @@ def RegisterHandlers(dp : Dispatcher):
edit_keyboard_func = GetEditNeedKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(need_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_need_button_name)
RegisterEdit(edit_need_photo_button_name, FSMEditPhotoItem, need_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_need_name_button_name, FSMEditNameItem, need_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_need_desc_button_name, FSMEditDescItem, need_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_need_access_button_name, FSMEditAccessItem, need_edit_access_message, access_field, bd_item.FieldType.text)
RegisterEdit(edit_need_photo_button_name, FSMEditNeedPhotoItem, need_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_need_name_button_name, FSMEditNeedNameItem, need_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_need_desc_button_name, FSMEditNeedDescItem, need_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_need_access_button_name, FSMEditNeedAccessItem, need_edit_access_message, access_field, bd_item.FieldType.text)

72
bot_modules/projects.py

@ -19,16 +19,16 @@ class FSMCreateProject(StatesGroup):
desc = State()
photo = State()
class FSMEditPhotoItem(StatesGroup):
class FSMEditProjectPhotoItem(StatesGroup):
item_field = State()
class FSMEditNameItem(StatesGroup):
class FSMEditProjectNameItem(StatesGroup):
item_field = State()
class FSMEditDeskItem(StatesGroup):
class FSMEditProjectDeskItem(StatesGroup):
item_field = State()
class FSMEditAccessItem(StatesGroup):
class FSMEditProjectAccessItem(StatesGroup):
item_field = State()
# ---------------------------------------------------------
# БД
@ -271,17 +271,41 @@ def RegisterHandlers(dp : Dispatcher):
# Список проектов
dp.register_message_handler(simple_message.SimpleMessageTemplate(ProjectsOpen, defaul_keyboard_func, GetAccess), text = projects_button_name)
bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, list_project_button_name, table_name, key_name, ShowMessageTemplate(project_open_message, GetViewItemInlineKeyboardTemplate), GetButtonNameAndKeyValueAndAccess, select_project_message, GetAccess, defaul_keyboard_func)
bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, \
list_project_button_name, \
table_name, \
key_name, \
ShowMessageTemplate(project_open_message, GetViewItemInlineKeyboardTemplate), \
GetButtonNameAndKeyValueAndAccess, \
select_project_message, \
GetAccess, \
defaul_keyboard_func\
)
# Удаление проекта
bd_item_delete.DeleteBDItemRegisterHandlers(dp, None, bd_item.GetCheckForTextFunc(del_project_button_name), table_name, key_name, None, ProjectPreDelete, ProjectPostDelete, GetButtonNameAndKeyValueAndAccess, select_project_message, GetAccess, defaul_keyboard_func)
bd_item_delete.DeleteBDItemRegisterHandlers(dp, \
None, \
bd_item.GetCheckForTextFunc(del_project_button_name), \
table_name, \
key_name, \
None, \
ProjectPreDelete, \
ProjectPostDelete, \
GetButtonNameAndKeyValueAndAccess, \
select_project_message, \
GetAccess, \
defaul_keyboard_func\
)
# Добавление проекта
bd_item_add.AddBDItem3RegisterHandlers(dp, \
bd_item.GetCheckForTextFunc(add_project_button_name), \
FSMCreateProject, FSMCreateProject.name,\
FSMCreateProject.desc, FSMCreateProject.photo,\
AddBDItemFunc, SimpleMessageTemplate(project_create_name_message), \
FSMCreateProject,\
FSMCreateProject.name,\
FSMCreateProject.desc, \
FSMCreateProject.photo,\
AddBDItemFunc, \
SimpleMessageTemplate(project_create_name_message), \
SimpleMessageTemplate(project_create_desc_message), \
SimpleMessageTemplate(project_create_photo_message), \
SimpleMessageTemplate(project_success_create_message), \
@ -296,10 +320,30 @@ def RegisterHandlers(dp : Dispatcher):
GetStartProjectKeyboardButtons\
)
edit_keyboard_func = GetEditProjectKeyboardButtons
# Редактирование проекта
edit_keyboard_func = GetEditProjectKeyboardButtons
def RegisterEdit(a_ButtonName, a_FSM, a_EditMessage, a_FieldName, a_FieldType, a_AccessMode = user_access.AccessMode.EDIT):
bd_item_edit.EditBDItemRegisterHandlers(dp, \
None, \
a_FSM, \
bd_item.GetCheckForTextFunc(a_ButtonName), \
project_select_to_edit_message, \
ShowMessageTemplate(a_EditMessage), \
ShowMessageTemplate(project_success_edit_message), \
table_name, \
key_name, \
None, \
a_FieldName, \
GetButtonNameAndKeyValueAndAccess, \
GetAccess, \
edit_keyboard_func, \
access_mode = a_AccessMode, \
field_type = a_FieldType\
)
dp.register_message_handler(simple_message.InfoMessageTemplate(project_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_project_button_name)
bd_item_edit.EditBDItemRegisterHandlers(dp, None, FSMEditPhotoItem, bd_item.GetCheckForTextFunc(edit_project_photo_button_name), project_select_to_edit_message, ShowMessageTemplate(project_edit_photo_message), ShowMessageTemplate(project_success_edit_message), table_name, key_name, None, photo_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.photo)
bd_item_edit.EditBDItemRegisterHandlers(dp, None, FSMEditNameItem, bd_item.GetCheckForTextFunc(edit_project_name_button_name), project_select_to_edit_message, ShowMessageTemplate(project_edit_name_message), ShowMessageTemplate(project_success_edit_message), table_name, key_name, None, name_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text)
bd_item_edit.EditBDItemRegisterHandlers(dp, None, FSMEditDeskItem, bd_item.GetCheckForTextFunc(edit_project_desc_button_name), project_select_to_edit_message, ShowMessageTemplate(project_edit_desc_message), ShowMessageTemplate(project_success_edit_message), table_name, key_name, None, desc_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.EDIT, field_type = bd_item.FieldType.text)
bd_item_edit.EditBDItemRegisterHandlers(dp, None, FSMEditAccessItem, bd_item.GetCheckForTextFunc(edit_project_access_button_name), project_select_to_edit_message, ShowMessageTemplate(project_edit_access_message), ShowMessageTemplate(project_success_edit_message), table_name, key_name, None, access_field, GetButtonNameAndKeyValueAndAccess, GetAccess, edit_keyboard_func, access_mode = user_access.AccessMode.ACCEES_EDIT, field_type = bd_item.FieldType.text)
RegisterEdit(edit_project_photo_button_name, FSMEditProjectPhotoItem, project_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_project_name_button_name, FSMEditProjectNameItem, project_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_project_desc_button_name, FSMEditProjectDeskItem, project_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_project_access_button_name, FSMEditProjectAccessItem, project_edit_access_message, access_field, bd_item.FieldType.text)

16
bot_modules/tasks.py

@ -19,19 +19,19 @@ class FSMCreateTask(StatesGroup):
desc = State()
photo = State()
class FSMEditPhotoItem(StatesGroup):
class FSMEditTaskPhotoItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditNameItem(StatesGroup):
class FSMEditTaskNameItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditDescItem(StatesGroup):
class FSMEditTaskDescItem(StatesGroup):
item_id = State()
item_field = State()
class FSMEditAccessItem(StatesGroup):
class FSMEditTaskAccessItem(StatesGroup):
item_id = State()
item_field = State()
# ---------------------------------------------------------
@ -367,7 +367,7 @@ def RegisterHandlers(dp : Dispatcher):
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)
RegisterEdit(edit_task_photo_button_name, FSMEditPhotoItem, task_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_task_name_button_name, FSMEditNameItem, task_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_task_desc_button_name, FSMEditDescItem, task_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_task_access_button_name, FSMEditAccessItem, task_edit_access_message, access_field, bd_item.FieldType.text)
RegisterEdit(edit_task_photo_button_name, FSMEditTaskPhotoItem, task_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_task_name_button_name, FSMEditTaskNameItem, task_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_task_desc_button_name, FSMEditTaskDescItem, task_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_task_access_button_name, FSMEditTaskAccessItem, task_edit_access_message, access_field, bd_item.FieldType.text)

Loading…
Cancel
Save