From 5dd44fe7f22014f75dd3350d1aa17afd505047ca Mon Sep 17 00:00:00 2001 From: Alexei Date: Sat, 30 Sep 2023 23:39:54 +0300 Subject: [PATCH 1/8] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=BC=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=B1=D0=BB=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + bot_modules/authorize.py | 231 +++++++++++++++++++++++++++++++++++++++++++++++ bot_sys/bd_table.py | 8 ++ main.py | 7 +- 4 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 bot_modules/authorize.py diff --git a/.gitignore b/.gitignore index e3f5dc5..a67820b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ config_root_ids __pycache__ log.txt bot.db +tmp.py diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py new file mode 100644 index 0000000..2831c0a --- /dev/null +++ b/bot_modules/authorize.py @@ -0,0 +1,231 @@ +# -*- coding: utf8 -*- +# Общественное достояние, 2023, Алексей Безбородов (Alexei Bezborodov) + +# Авторизация или регистрация в кооперативе или другой организации + +from bot_sys import bot_bd, keyboard, user_access, bd_table, bot_subscribes +from bot_modules import mod_table_operate, mod_simple_message + +from enum import Enum +from enum import auto +# --------------------------------------------------------- +# БД +module_name = 'authorize' + +table_name = module_name +user_id_field = 'userID' +user_name_field = 'userName' +user_family_name_field = 'userFamilyName' +user_middle_name_field = 'userMiddleName' +user_birthday_field = 'userBirthday' +user_address_field = 'userAddress' +user_contacts_field = 'userContacts' +user_confirm_field = 'userConfirm' +access_field = 'authorizeAccess' +create_datetime_field = 'authorizeCreateDateTime' + +user_id_table_field = bd_table.TableField(user_id_field, bd_table.TableFieldDestiny.USER_ID, bd_table.TableFieldType.INT) + +class ConfirmStatus(Enum): + YES = auto() + NO = auto() + +table = bd_table.Table(table_name, [ + user_id_table_field, + bd_table.TableField(user_name_field, bd_table.TableFieldDestiny.USER_NAME, bd_table.TableFieldType.STR), + bd_table.TableField(user_family_name_field, bd_table.TableFieldDestiny.USER_FAMILY_NAME, bd_table.TableFieldType.STR), + bd_table.TableField(user_middle_name_field, bd_table.TableFieldDestiny.USER_MIDDLE_NAME, bd_table.TableFieldType.STR), + bd_table.TableField(user_birthday_field, bd_table.TableFieldDestiny.USER_BIRTHDAY, bd_table.TableFieldType.STR), + bd_table.TableField(user_address_field, bd_table.TableFieldDestiny.USER_ADDRESS, bd_table.TableFieldType.STR), + bd_table.TableField(user_contacts_field, bd_table.TableFieldDestiny.USER_CONTACTS, bd_table.TableFieldType.STR), + bd_table.TableField(user_confirm_field, bd_table.TableFieldDestiny.USER_CONFIRM, bd_table.TableFieldType.ENUM, a_Enum = ConfirmStatus), + bd_table.TableField(access_field, bd_table.TableFieldDestiny.ACCESS, bd_table.TableFieldType.STR), + bd_table.TableField(create_datetime_field, bd_table.TableFieldDestiny.CREATE_DATE, bd_table.TableFieldType.STR), + ] + , + [ + [user_id_table_field], + ] + ) + +init_access = f'{user_access.user_access_group_new}=va' + +# --------------------------------------------------------- +# Сообщения и кнопки + +class ButtonNames(Enum): + LIST_AUTH_DOCS = auto() + +button_names = { + mod_simple_message.ButtonNames.START: "🔑 Авторизация", + mod_table_operate.ButtonNames.LIST: "≣ Список авторизаций пользователей", + mod_table_operate.ButtonNames.ADD: "📨 Заявка на вступление", + mod_table_operate.ButtonNames.EDIT: "🛠 Редактировать свои данные", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_NAME): "☐ Изменить имя пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_FAMILY_NAME): "☐ Изменить фамилию пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_MIDDLE_NAME): "☐ Изменить отчество пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_BIRTHDAY): "☐ Изменить дату рождения пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ADDRESS): "☐ Изменить адрес пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONTACTS): "☐ Изменить контакты пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONFIRM): "☐ Изменить подтверждение пользователя", +# mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", mod_table_operate.ButtonNames.DEL: "❌ Удалить авторизацию пользователя", +} + +messages = { + mod_simple_message.Messages.START: f''' +{button_names[mod_simple_message.ButtonNames.START]} + +''', + mod_table_operate.Messages.SELECT: ''' +Пожалуйста, выберите пользователя: +''', + mod_table_operate.Messages.ERROR_FIND: ''' +❌ Ошибка, пользователь не найден +''', + mod_table_operate.Messages.OPEN: f''' +Пользователь: #{user_id_field} + +Имя: #{user_name_field} +Фамилия: #{user_family_name_field} +Отчество: #{user_middle_name_field} +Дата рождения: #{user_birthday_field} +Адрес: #{user_address_field} +Контакты: #{user_contacts_field} +Подтверждение авторизации: #{user_confirm_field} + +Время создания: #{create_datetime_field} +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_NAME): ''' +Авторизация. Шаг №1 + +Введите своё имя: +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_FAMILY_NAME): ''' +Авторизация. Шаг №2 + +Введите свою фамилию: +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_MIDDLE_NAME): ''' +Авторизация. Шаг №3 + +Введите своё отчество: +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_BIRTHDAY): ''' +Авторизация. Шаг №4 + +Введите свою дату рождения в формате ДД.ММ.ГГГГ: +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_ADDRESS): ''' +Авторизация. Шаг №5 + +Введите свой домашний адрес: +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_CONTACTS): ''' +Авторизация. Шаг №6 + +Введите свои контакты: +''', + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_CONFIRM): ''' +Авторизация. Шаг №7 + +Имя: #{user_name_field} +Фамилия: #{user_family_name_field} +Отчество: #{user_middle_name_field} +Дата рождения: #{user_birthday_field} +Адрес: #{user_address_field} +Контакты: #{user_contacts_field} +Подтверждение авторизации: #{user_confirm_field} + +Подтвердите свои данные: +''', + + mod_table_operate.Messages.SUCCESS_CREATE: '''✅ Вы успешно зарегистрированы! Посмотрите документы и отправьте фотографии подписанных документов''', + mod_table_operate.Messages.START_EDIT: ''' +Пожалуйста, выберите действие: +''', + mod_table_operate.Messages.SELECT_TO_EDIT: ''' +Выберите пользователя, у которого вы хотите отредактировать данные. +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_NAME): f''' +Текущее имя пользователя: +#{user_name_field} + +Введите новое имя пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_FAMILY_NAME): f''' +Текущая фамилия пользователя: +#{user_family_name_field} + +Введите новую фамилию пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_MIDDLE_NAME): f''' +Текущее отчество пользователя: +#{user_middle_name_field} + +Введите новое отчество пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_BIRTHDAY): f''' +Текущая дата рождения пользователя: +#{user_birthday_field} + +Введите новую дату рождения пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_ADDRESS): f''' +Текущий адрес пользователя: +#{user_address_field} + +Введите новый адрес пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_CONTACTS): f''' +Текущие контакты пользователя: +#{user_contacts_field} + +Введите новые контакты пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.USER_CONFIRM): f''' +Текущее подтвержение пользователя: +#{user_confirm_field} + +Введите новое подтверждение пользователя: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.ACCESS): f''' +Текущий доступ к проекту: +#{access_field} + +{user_access.user_access_readme} + +Введите новую строку доступа: +''', + mod_table_operate.Messages.SUCCESS_EDIT: '''✅ Проект успешно отредактирован!''', + mod_table_operate.Messages.SELECT_TO_DELETE: ''' +Выберите пользователя, у которого вы хотите удалить авторизованные данные. +''', + mod_table_operate.Messages.SUCCESS_DELETE: '''✅ Данные пользователя успешно удалены!''', +} + +messages_subscribes = { + mod_table_operate.SubscribeMessage(bot_subscribes.SubscribeType.ADD):f'''Данные по авторизации созданы''', + mod_table_operate.SubscribeMessage(bot_subscribes.SubscribeType.ANY_ITEM_EDIT):f'''Данные по авторизации отредактированы''', + mod_table_operate.SubscribeMessage(bot_subscribes.SubscribeType.ANY_ITEM_DEL):f'''Данные по авторизации удалены''', + mod_table_operate.SubscribeMessage(bot_subscribes.SubscribeType.ITEM_EDIT):f'''Данные по авторизации отредактированы #item_id''', + mod_table_operate.SubscribeMessage(bot_subscribes.SubscribeType.ITEM_DEL):f'''Данные по авторизации удалены #item_id''', +} + +messages.update(messages_subscribes) + +messages_order_status = { + mod_table_operate.EnumMessageForView(ConfirmStatus.YES): f'''Да, все данные верны''', + mod_table_operate.EnumMessageForView(ConfirmStatus.NO): f'''Нет, данные не верны''', +} + +messages.update(messages_order_status) + +class ModuleAuthorize(mod_table_operate.TableOperateModule): + def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + + def GetName(self): + return module_name + diff --git a/bot_sys/bd_table.py b/bot_sys/bd_table.py index 593b146..b5b98d6 100644 --- a/bot_sys/bd_table.py +++ b/bot_sys/bd_table.py @@ -38,6 +38,14 @@ class TableFieldDestiny(Enum): OTHER = auto() VERSION_NUMBER = auto() SUB_VERSION_NUMBER = auto() + USER_ID = auto() + USER_NAME = auto() # Имя + USER_FAMILY_NAME = auto() # Фамилия + USER_MIDDLE_NAME = auto() # Отчество + USER_BIRTHDAY = auto() # Дата рождения + USER_ADDRESS = auto() # Адресс + USER_CONTACTS = auto() # контакты + USER_CONFIRM = auto() # подтверждение class TableField: def __init__(self, a_Name, a_Destiny : TableFieldDestiny, a_Type : TableFieldType, a_Enum = None): diff --git a/main.py b/main.py index 3ed4e1f..b064418 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ import os from bot_sys import config, log, aiogram_bot, bot_messages, bd_table, user_access from bot_modules import mod_agregator, start, profile, backup, users_groups_agregator, access, projects, tasks, needs, comments from bot_modules import languages, messages, buttons, users, groups, user_in_groups -from bot_modules import orders, all_orders +from bot_modules import orders, all_orders, authorize from bot_modules import bd_version from bot_sys import bot_subscribes @@ -110,6 +110,10 @@ g_ModuleAgregator.AddModule(mod_subscribe) mod_bd_version = bd_version.ModuleBDVersion(g_Bot, g_ModuleAgregator, g_BotMessages, g_BotButtons, g_BotSubscribes, g_Log) g_ModuleAgregator.AddModule(mod_bd_version) +child_mod_name_list = [mod_start_name] +mod_authorize = authorize.ModuleAuthorize(None, None, child_mod_name_list, start_mod_list, g_Bot, g_ModuleAgregator, g_BotMessages, g_BotButtons, g_BotSubscribes, g_Log) +g_ModuleAgregator.AddModule(mod_authorize) + child_mod_name_list = [ mod_profile.GetName(), mod_backup.GetName(), @@ -121,6 +125,7 @@ child_mod_name_list = [ mod_all_orders.GetName(), mod_subscribe.GetName(), mod_bd_version.GetName(), + mod_authorize.GetName(), ] mod_start = start.ModuleStart(child_mod_name_list, g_Bot, g_ModuleAgregator, g_BotMessages, g_BotButtons, g_BotSubscribes, g_Log) g_ModuleAgregator.AddModule(mod_start) From 1a388229e830d9f23b94882fa6553a2a4c5c2aca Mon Sep 17 00:00:00 2001 From: Alexei Date: Sun, 8 Oct 2023 23:34:33 +0300 Subject: [PATCH 2/8] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=20=D1=81=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth_docs/test_doc.odt | 273 +++++++++++++++++++++++++++++++++++++++ bot_modules/authorize.py | 128 ++++++++++++++++-- bot_modules/mod_table_operate.py | 11 +- bot_sys/bot_bd.py | 1 + bot_sys/user_access.py | 2 + config_auth_docs | 1 + requirements.txt | 1 + template/docs_message.py | 77 +++++++++++ template/file_message.py | 2 +- 9 files changed, 480 insertions(+), 16 deletions(-) create mode 100644 auth_docs/test_doc.odt create mode 100644 config_auth_docs create mode 100644 template/docs_message.py diff --git a/auth_docs/test_doc.odt b/auth_docs/test_doc.odt new file mode 100644 index 0000000..6047b4a --- /dev/null +++ b/auth_docs/test_doc.odt @@ -0,0 +1,273 @@ + + + + 2023-10-08T23:17:27.894126099PT46S2LibreOffice/7.3.6.2$Linux_X86_64 LibreOffice_project/30$Build-2 + + + 0 + 0 + 35588 + 13813 + true + false + + + view2 + 22826 + 5909 + 0 + 0 + 35586 + 13811 + 0 + 1 + false + 100 + false + false + false + + + + + false + false + false + true + true + true + true + true + false + 0 + false + false + false + true + false + false + true + false + false + false + false + true + true + true + false + false + false + false + false + false + false + true + false + false + true + false + false + false + true + 0 + 1 + true + false + + high-resolution + true + + + false + false + true + false + true + true + false + true + + true + 820887 + + true + false + true + true + 0 + + false + false + false + true + false + true + false + false + false + false + true + false + false + + false + false + true + false + false + false + false + false + false + false + false + false + 820887 + false + false + false + false + false + true + false + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bd_table.TableFieldDestiny.USER_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_FAMILY_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_MIDDLE_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_BIRTHDAY: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_ADDRESS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_CONTACTS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_CONFIRM: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.ACCESS: user_access.AccessMode.NONE, + + + \ No newline at end of file diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py index 2831c0a..e2f515e 100644 --- a/bot_modules/authorize.py +++ b/bot_modules/authorize.py @@ -3,8 +3,9 @@ # Авторизация или регистрация в кооперативе или другой организации -from bot_sys import bot_bd, keyboard, user_access, bd_table, bot_subscribes +from bot_sys import bot_bd, keyboard, user_access, bd_table, bot_subscribes, config from bot_modules import mod_table_operate, mod_simple_message +from template import docs_message from enum import Enum from enum import auto @@ -50,6 +51,12 @@ table = bd_table.Table(table_name, [ init_access = f'{user_access.user_access_group_new}=va' +def GetAuthorizeItem(a_Bot, a_UserID): + items = bd_item.GetBDItemsTemplate(a_Bot, table_name, user_id_field)(a_UserID) + if len(items) == 1: + return items[0] + return None + # --------------------------------------------------------- # Сообщения и кнопки @@ -60,24 +67,35 @@ button_names = { mod_simple_message.ButtonNames.START: "🔑 Авторизация", mod_table_operate.ButtonNames.LIST: "≣ Список авторизаций пользователей", mod_table_operate.ButtonNames.ADD: "📨 Заявка на вступление", + ButtonNames.LIST_AUTH_DOCS: "📨 Регистрационные документы", mod_table_operate.ButtonNames.EDIT: "🛠 Редактировать свои данные", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_NAME): "☐ Изменить имя пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_FAMILY_NAME): "☐ Изменить фамилию пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_MIDDLE_NAME): "☐ Изменить отчество пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_BIRTHDAY): "☐ Изменить дату рождения пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ADDRESS): "☐ Изменить адрес пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONTACTS): "☐ Изменить контакты пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONFIRM): "☐ Изменить подтверждение пользователя", -# mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", - mod_table_operate.EditButton(bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", mod_table_operate.ButtonNames.DEL: "❌ Удалить авторизацию пользователя", + bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", + bd_table.TableFieldDestiny.USER_NAME): "☐ Изменить имя пользователя", + bd_table.TableFieldDestiny.USER_FAMILY_NAME): "☐ Изменить фамилию пользователя", + bd_table.TableFieldDestiny.USER_MIDDLE_NAME): "☐ Изменить отчество пользователя", + bd_table.TableFieldDestiny.USER_BIRTHDAY): "☐ Изменить дату рождения пользователя", + bd_table.TableFieldDestiny.USER_ADDRESS): "☐ Изменить адрес пользователя", + bd_table.TableFieldDestiny.USER_CONTACTS): "☐ Изменить контакты пользователя", + bd_table.TableFieldDestiny.USER_CONFIRM): "☐ Изменить подтверждение пользователя", +# bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", + bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", mod_table_operate.ButtonNames.DEL: "❌ Удалить авторизацию пользователя", } +class Messages(Enum): + LIST_AUTH_DOCS = auto() + LIST_AUTH_DOCS_ERROR = auto() + messages = { mod_simple_message.Messages.START: f''' {button_names[mod_simple_message.ButtonNames.START]} ''', + Messages.LIST_AUTH_DOCS: ''' +ваши регистрационные документы: +''', + Messages.LIST_AUTH_DOCS_ERROR: ''' +Ошибка получения документов. Обратитесь в техподдержку. +''', mod_table_operate.Messages.SELECT: ''' Пожалуйста, выберите пользователя: ''', @@ -229,3 +247,91 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): def GetName(self): return module_name + def GetAccessForEditKeyboardButtons(self, a_Field): + cur_dict = { + bd_table.TableFieldDestiny.USER_ID: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_FAMILY_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_MIDDLE_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_BIRTHDAY: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_ADDRESS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_CONTACTS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_CONFIRM: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.ACCESS: user_access.AccessMode.NONE, + } + return cur_dict.get(a_Field.m_Destiny, super().GetAccessForEditKeyboardButtons(a_Field)) + + def GetButtonNameAndKeyValueAndAccess(self, a_Item): + key_name_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_ID) + name_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_NAME) + fam_name_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_FAMILY_NAME) + access_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.ACCESS) + assert key_name_id != None + assert name_field_id != None + assert fam_name_field_id != None + assert access_field_id != None + return \ + a_Item[name_field_id] + ' ' + a_Item[fam_name_field_id] + '(' + a_Item[key_name_id] +')',\ + a_Item[key_name_id],\ + a_Item[access_field_id] + + def GetStartKeyboardButtons(self, a_Message, a_UserGroups): + parent_buttons = super().GetStartKeyboardButtons(a_Message, a_UserGroups) + user_id = str(a_Message.from_user.id) + item = GetAuthorizeItem(self.m_Bot, user_id) + user_confirm_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_CONFIRM) + cur_buttons = [] + if item and item[user_confirm_field_id] == str(ConfirmStatus.YES): + cur_buttons += [ + keyboard.ButtonWithAccess(self.GetButton(ButtonNames.LIST_AUTH_DOCS), user_access.AccessMode.VIEW, self.GetAccess()), + ] + return parent_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) + + def RegisterHandlers(self): + super().RegisterHandlers() + + def GetFilesFunc(a_user_id): + files = GetAuthDocs() + cur_dict = GetReplaceDictFunc(self.m_Bot, a_user_id) + result = {} + for f in files: + result.update({f, cur_dict}) + return result + + button_name = self.GetButton(ButtonNames.LIST_AUTH_DOCS) + if button_name: + self.m_Bot.RegisterMessageHandler( + docs_message.BackupFileTemplate( + self.m_Bot, + GetFilesFunc, + self.GetMessage(Messages.LIST_AUTH_DOCS), + self.m_GetAccessFunc, + self.m_GetStartKeyboardButtonsFunc, + None, + self.GetMessage(Messages.LIST_AUTH_DOCS_ERROR), + access_mode = user_access.AccessMode.VIEW + ), + bd_item.GetCheckForTextFunc(button_name) + ) + +def GetReplaceDictFunc(a_Bot, a_user_id): + item = GetAuthorizeItem(self.m_Bot, user_id) + if not item: + return None + result = {} + i = 0 + for f in table: + result.update({str(f.m_Destiny), item[i]}) + i += 1 + return result + +auth_docs_file_name = 'config_auth_docs' + +def GetAuthDocs(): + global g_auth_docs + if len(g_auth_docs) == 0: + root_ids = config.GetAllLinesFromFile(auth_docs_file_name) + for i in root_ids: + g_auth_docs += [config.ClearReadLine(i)] + + return g_auth_docs diff --git a/bot_modules/mod_table_operate.py b/bot_modules/mod_table_operate.py index acff162..e927b0d 100644 --- a/bot_modules/mod_table_operate.py +++ b/bot_modules/mod_table_operate.py @@ -126,13 +126,16 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): ] return mod_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) + def GetAccessForEditKeyboardButtons(self, a_Field): + if a_Field.m_Destiny == bd_table.TableFieldDestiny.ACCESS or a_Field.m_Destiny == bd_table.TableFieldDestiny.DEFAULT_ACCESS: + return user_access.AccessMode.ACCEES_EDIT + return user_access.AccessMode.EDIT + def GetEditKeyboardButtons(self, a_Message, a_UserGroups): mod_buttons = keyboard.MakeButtons(self.m_Bot, self.GetButtons(self.m_EditModuleNameList), a_UserGroups) cur_buttons = [] for f in self.m_Table.GetFields(): - access = user_access.AccessMode.EDIT - if f.m_Destiny == bd_table.TableFieldDestiny.ACCESS or f.m_Destiny == bd_table.TableFieldDestiny.DEFAULT_ACCESS: - access = user_access.AccessMode.ACCEES_EDIT + access = self.GetAccessForEditKeyboardButtons(f) cur_buttons += [keyboard.ButtonWithAccess(self.GetButton(EditButton(f.m_Destiny)), access, self.GetAccess()),] return mod_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) @@ -185,7 +188,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): def ShowMessageTemplate(self, a_Message, Inline_keyboard_template_func = None, a_EnablePhoto = False): async def ShowMessage(a_CallbackQuery, a_Item): msg = a_Message.StaticCopy() - # TODO: добавить поддержку языка в a_MessageName + # TODO: добавить поддержку языков в a_MessageName Inline_keyboard_func = None item_access = None if a_Item: diff --git a/bot_sys/bot_bd.py b/bot_sys/bot_bd.py index ec81174..47583b2 100644 --- a/bot_sys/bot_bd.py +++ b/bot_sys/bot_bd.py @@ -9,6 +9,7 @@ from bot_sys import log def GetBDDateTimeNow(): return 'datetime(\'now\')' +# TODO: Удалить что-то из SelectBDTemplate RequestSelectTemplate def SelectBDTemplate(a_Bot, a_TableName): def SelectBD(): return a_Bot.SQLRequest(f'SELECT * FROM {a_TableName}') diff --git a/bot_sys/user_access.py b/bot_sys/user_access.py index abe3127..29750ca 100644 --- a/bot_sys/user_access.py +++ b/bot_sys/user_access.py @@ -32,11 +32,13 @@ ACCEES_EDIT = 'r' - изменение прав доступа # Типы уровня доступа class AccessMode(Enum): + NONE = '-' VIEW = 'v' ADD = 'a' EDIT = 'e' DELETE = 'd' ACCEES_EDIT = 'r' + ALL = '+' class UserGroups: def __init__(self, a_UserID : str, a_GroupNamesList : [str]): diff --git a/config_auth_docs b/config_auth_docs new file mode 100644 index 0000000..7822470 --- /dev/null +++ b/config_auth_docs @@ -0,0 +1 @@ +auth_docs/test_doc.odt diff --git a/requirements.txt b/requirements.txt index e99a1ef..9e91223 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ aiogram==2.20 colorama==0.4.5 +odfpy diff --git a/template/docs_message.py b/template/docs_message.py new file mode 100644 index 0000000..7544125 --- /dev/null +++ b/template/docs_message.py @@ -0,0 +1,77 @@ +# -*- coding: utf8 -*- +# Общественное достояние 2023, Алексей Безбородов (Alexei Bezborodov) + +# Сообщения для работы с документами + +from bot_sys import log, config, user_access +from bot_modules import groups_utils +from template import simple_message +import odf + +def DocFilesTemplate(a_Bot, a_FilesFunc, a_CaptionMessage, a_AccessFunc, a_GetButtonsFunc, a_GetInlineButtonsFunc, a_ErrorMessage, access_mode = user_access.AccessMode.EDIT): + async def DocFiles(a_Message): + user_id = str(a_Message.from_user.id) + user_groups= groups_utils.GetUserGroupData(a_Bot, user_id) + if not user_access.CheckAccess(a_Bot.GetRootIDs(), a_AccessFunc(), user_groups, access_mode): + return await simple_message.AccessDeniedMessage(a_Bot, a_GetButtonsFunc, user_id, a_Message, user_groups) + + msg = a_CaptionMessage.GetDesc() + msg = msg.replace('@time', a_Bot.GetLog().GetTime()) + + files = a_FilesFunc(user_id) + if not files: + await simple_message.SendMessage(a_Bot, a_ErrorMessage, a_GetButtonsFunc, None, user_id, a_Message, user_groups) + return + + for file_path, dict_replace in files.values(): + if not dict_replace: + continue + new_file = await MakeDocFile(a_Bot, file_path, dict_replace, user_id) + document = await GetFile(a_Bot, file_path) + if document is None: + await simple_message.SendMessage(a_Bot, a_ErrorMessage, a_GetButtonsFunc, None, user_id, a_Message, user_groups) + else: + await a_Bot.SendDocument( + user_id, + document, + msg, + simple_message.ProxyGetButtonsTemplate(a_GetButtonsFunc)(a_Message, user_groups), + simple_message.ProxyGetButtonsTemplate(a_GetInlineButtonsFunc)(a_Message, user_groups) + ) + return DocFiles + +async def MakeDocFile(a_Bot, a_FilePath, a_DictReplace, a_user_id): + document = odf.opendocument.load(a_FilePath) + if document == None: + a_Bot.GetLog().Error(f'Не удалось загрузить файл {a_FilePath}.') + return None + + for element in document.getElementsByType(text.Span): + extracted_text = odf.teletype.extractText(element) + + for file_path, dict_replace in a_DictReplace.values(): + if extracted_text.find('Replace this') != -1: + extracted_text = extracted_text.replace('Replace this', 'to this') + + new_element = odf.text.Span() + new_element.setAttribute('stylename', element.getAttribute('stylename')) + new_element.addText(extracted_text) + + element.parentNode.insertBefore(new_element, element) + element.parentNode.removeChild(element) + + new_file_path = a_FilePath[:-4] + new_file_path += f"{a_user_id}.odt" + document.save(new_file_path) + return new_file_path + +async def GetFile(a_Bot, a_Path): + if not a_Path: + return None + try: + document = open(a_Path, 'rb') + a_Bot.GetLog().Success(f'Загружен файл {a_Path}') + return document + except Exception as e: + a_Bot.GetLog().Error(f'Не удалось загрузить файл {a_Path}. Ошибка {str(e)}') + return None diff --git a/template/file_message.py b/template/file_message.py index fe7e6a7..0159aa3 100644 --- a/template/file_message.py +++ b/template/file_message.py @@ -16,7 +16,7 @@ def BackupFileTemplate(a_Bot, a_Path, a_CaptionMessage, a_AccessFunc, a_GetButto document = await GetFile(a_Bot, a_Path) if document is None: - return simple_message.SendMessage(a_Bot, a_ErrorMessage, a_GetButtonsFunc, None, user_id, a_Message, user_groups) + return await simple_message.SendMessage(a_Bot, a_ErrorMessage, a_GetButtonsFunc, None, user_id, a_Message, user_groups) msg = a_CaptionMessage.GetDesc() msg = msg.replace('@time', a_Bot.GetLog().GetTime()) From d7ea8ecd756f4c62e24f4ac4c02cf18cc7191d3a Mon Sep 17 00:00:00 2001 From: Alexei Date: Fri, 13 Oct 2023 20:54:52 +0300 Subject: [PATCH 3/8] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20=D0=B4=D0=BE=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20=D0=B4=D0=BE=D0=BA=D1=83?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth_docs/test_doc.odt | 51 ++++++++++++++++++++++++++-------------- bot_modules/authorize.py | 38 ++++++++++++++++++------------ bot_modules/mod_table_operate.py | 48 +++++++++++++++++++++++++++++++------ bot_modules/subscribes.py | 7 ------ bot_sys/bd_table.py | 7 ++++++ template/bd_item.py | 2 +- template/bd_item_add.py | 4 ++-- 7 files changed, 107 insertions(+), 50 deletions(-) diff --git a/auth_docs/test_doc.odt b/auth_docs/test_doc.odt index 6047b4a..abc5c88 100644 --- a/auth_docs/test_doc.odt +++ b/auth_docs/test_doc.odt @@ -1,7 +1,7 @@ - 2023-10-08T23:17:27.894126099PT46S2LibreOffice/7.3.6.2$Linux_X86_64 LibreOffice_project/30$Build-2 + 2023-10-13T15:56:51.616305329PT1M19S4LibreOffice/7.3.6.2$Linux_X86_64 LibreOffice_project/30$Build-2 0 @@ -13,8 +13,8 @@ view2 - 22826 - 5909 + 18221 + 3475 0 0 35586 @@ -88,7 +88,7 @@ true true - 820887 + 918403 true false @@ -149,7 +149,7 @@ - + @@ -184,52 +184,52 @@ - + - + - + - + - + - + - + - + - + - + @@ -240,16 +240,22 @@ + + + - + + + + - + @@ -260,13 +266,22 @@ - bd_table.TableFieldDestiny.USER_NAME: user_access.AccessMode.NONE, + + + bd_table.TableFieldDestiny.USER_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_FAMILY_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_MIDDLE_NAME: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_BIRTHDAY: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_ADDRESS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_CONTACTS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.USER_CONFIRM: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.ACCESS: user_access.AccessMode.NONE, diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py index e2f515e..e7250d4 100644 --- a/bot_modules/authorize.py +++ b/bot_modules/authorize.py @@ -5,7 +5,7 @@ from bot_sys import bot_bd, keyboard, user_access, bd_table, bot_subscribes, config from bot_modules import mod_table_operate, mod_simple_message -from template import docs_message +from template import docs_message, bd_item from enum import Enum from enum import auto @@ -69,16 +69,19 @@ button_names = { mod_table_operate.ButtonNames.ADD: "📨 Заявка на вступление", ButtonNames.LIST_AUTH_DOCS: "📨 Регистрационные документы", mod_table_operate.ButtonNames.EDIT: "🛠 Редактировать свои данные", - bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", - bd_table.TableFieldDestiny.USER_NAME): "☐ Изменить имя пользователя", - bd_table.TableFieldDestiny.USER_FAMILY_NAME): "☐ Изменить фамилию пользователя", - bd_table.TableFieldDestiny.USER_MIDDLE_NAME): "☐ Изменить отчество пользователя", - bd_table.TableFieldDestiny.USER_BIRTHDAY): "☐ Изменить дату рождения пользователя", - bd_table.TableFieldDestiny.USER_ADDRESS): "☐ Изменить адрес пользователя", - bd_table.TableFieldDestiny.USER_CONTACTS): "☐ Изменить контакты пользователя", - bd_table.TableFieldDestiny.USER_CONFIRM): "☐ Изменить подтверждение пользователя", -# bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", - bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", mod_table_operate.ButtonNames.DEL: "❌ Удалить авторизацию пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_NAME): "☐ Изменить имя пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_FAMILY_NAME): "☐ Изменить фамилию пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_MIDDLE_NAME): "☐ Изменить отчество пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_BIRTHDAY): "☐ Изменить дату рождения пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ADDRESS): "☐ Изменить адрес пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONTACTS): "☐ Изменить контакты пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONFIRM): "☐ Изменить подтверждение пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", + mod_table_operate.ButtonNames.DEL: "❌ Удалить авторизацию пользователя", + mod_table_operate.EnumButton(ConfirmStatus.YES): "Да, все данные верны", + mod_table_operate.EnumButton(ConfirmStatus.NO): "Нет, данные не верны", } class Messages(Enum): @@ -145,7 +148,7 @@ messages = { Введите свои контакты: ''', - mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_CONFIRM): ''' + mod_table_operate.CreateMessage(bd_table.TableFieldDestiny.USER_CONFIRM): f''' Авторизация. Шаг №7 Имя: #{user_name_field} @@ -233,12 +236,12 @@ messages_subscribes = { messages.update(messages_subscribes) -messages_order_status = { +messages_confirm_status = { mod_table_operate.EnumMessageForView(ConfirmStatus.YES): f'''Да, все данные верны''', mod_table_operate.EnumMessageForView(ConfirmStatus.NO): f'''Нет, данные не верны''', } -messages.update(messages_order_status) +messages.update(messages_confirm_status) class ModuleAuthorize(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): @@ -301,7 +304,7 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): button_name = self.GetButton(ButtonNames.LIST_AUTH_DOCS) if button_name: self.m_Bot.RegisterMessageHandler( - docs_message.BackupFileTemplate( + docs_message.DocFilesTemplate( self.m_Bot, GetFilesFunc, self.GetMessage(Messages.LIST_AUTH_DOCS), @@ -314,6 +317,11 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): bd_item.GetCheckForTextFunc(button_name) ) + def AddBDItemFunc(self, a_ItemData, a_UserID): + a_ItemData[user_id_field] = a_UserID + #a_ItemData[address_field] = '' + return super().AddBDItemFunc(a_ItemData, a_UserID) + def GetReplaceDictFunc(a_Bot, a_user_id): item = GetAuthorizeItem(self.m_Bot, user_id) if not item: diff --git a/bot_modules/mod_table_operate.py b/bot_modules/mod_table_operate.py index e927b0d..2fc8a8d 100644 --- a/bot_modules/mod_table_operate.py +++ b/bot_modules/mod_table_operate.py @@ -185,12 +185,32 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): a_Msg.UpdatePhotoID(','.join(photos)) return a_Msg + def UpdateMessageByDict(self, a_Msg, a_Lang, a_ItemDict, a_EnablePhoto = False): + a_Msg.UpdateDesc(self.m_Table.ReplaceAllFieldTagsByDict(a_Msg.GetDesc(), a_ItemDict)) + photos = [] + for f in self.m_Table.GetFields(): + if f.m_Type == bd_table.TableFieldType.ENUM: + for s in f.m_Enum: + msg = self.GetMessage(EnumMessageForView(s)) + if msg: + a_Msg.UpdateDesc(a_Msg.GetDesc().replace(str(s), str(msg.GetMessageForLang(a_Lang).StaticCopy()))) + elif f.m_Type == bd_table.TableFieldType.PHOTO: + if f.m_Name in a_ItemDict: + photos += [str(a_ItemDict[f.m_Name])] + if a_EnablePhoto: + a_Msg.UpdatePhotoID(','.join(photos)) + return a_Msg + def ShowMessageTemplate(self, a_Message, Inline_keyboard_template_func = None, a_EnablePhoto = False): - async def ShowMessage(a_CallbackQuery, a_Item): + async def ShowMessage(a_CallbackQuery, a_Item, a_ItemDict): msg = a_Message.StaticCopy() # TODO: добавить поддержку языков в a_MessageName Inline_keyboard_func = None item_access = None + if a_ItemDict: + lang = str(a_CallbackQuery.from_user.language_code) + msg = msg.GetMessageForLang(lang).StaticCopy() + msg = self.UpdateMessageByDict(msg, lang, a_ItemDict, a_EnablePhoto = a_EnablePhoto) if a_Item: if len(a_Item) < self.m_Table.GetFieldsCount() - 1: # Для проектов это нужно. Там на 1 меньше поле. TODO разделить отправку сообщений item_access и Inline_keyboard_func return simple_message.WorkFuncResult(self.GetMessage(Messages.ERROR_FIND)) @@ -207,7 +227,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): async def PreDelete(self, a_CallbackQuery, a_Item): if len(a_Item) < self.m_Table.GetFieldsCount(): - return simple_message.WorkFuncResult(error_find_proj_message) + return simple_message.WorkFuncResult(self.GetMessage(Messages.ERROR_FIND)) access = a_Item[self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.ACCESS)] return simple_message.WorkFuncResult(self.GetMessage(Messages.SUCCESS_DELETE), None, item_access = access) @@ -312,12 +332,12 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): return a_Prefix - def AdditionalKeyboardForEditTemplate(self, a_Field): + def AdditionalKeyboardForEditTemplate(self, a_Field, user_access = user_access.AccessMode.EDIT): if a_Field.m_Type == bd_table.TableFieldType.ENUM: def KeyboardButtons(a_Message, a_UserGroups): cur_buttons = [] for s in a_Field.m_Enum: - cur_buttons += [keyboard.ButtonWithAccess(self.GetButton(EnumButton(s)), user_access.AccessMode.EDIT, self.GetAccess()),] + cur_buttons += [keyboard.ButtonWithAccess(self.GetButton(EnumButton(s)), user_access, self.GetAccess()),] return keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) return KeyboardButtons return None @@ -386,9 +406,23 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): ) def GetAddFields(self): + good_destiny = ( + bd_table.TableFieldDestiny.NAME, + bd_table.TableFieldDestiny.DESC, + bd_table.TableFieldDestiny.PHOTO, + bd_table.TableFieldDestiny.SUBSCRIBE_TYPE, + bd_table.TableFieldDestiny.ITEM_ID, + bd_table.TableFieldDestiny.USER_NAME, + bd_table.TableFieldDestiny.USER_FAMILY_NAME, + bd_table.TableFieldDestiny.USER_MIDDLE_NAME, + bd_table.TableFieldDestiny.USER_BIRTHDAY, + bd_table.TableFieldDestiny.USER_ADDRESS, + bd_table.TableFieldDestiny.USER_CONTACTS, + bd_table.TableFieldDestiny.USER_CONFIRM, + ) fields = [] for f in self.m_Table.GetFields(): - if f.m_Destiny in (bd_table.TableFieldDestiny.NAME, bd_table.TableFieldDestiny.DESC, bd_table.TableFieldDestiny.PHOTO, bd_table.TableFieldDestiny.SUBSCRIBE_TYPE, bd_table.TableFieldDestiny.ITEM_ID, ): + if f.m_Destiny in good_destiny: fields += [f] return fields @@ -422,13 +456,13 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): f_id = 0 f = fields[f_id] - keyboard = bd_item.MixKeyboardFuncTemplate(self.AdditionalKeyboardForEditTemplate(f), GetKeyboard(f)) + keyboard = bd_item.MixKeyboardFuncTemplate(self.AdditionalKeyboardForEditTemplate(f, user_access.AccessMode.ADD), GetKeyboard(f)) reg_func(bd_item_add.StartAddBDItemTemplate(self.m_Bot, fsm, getattr(fsm, f'item{f_id}'), self.ShowMessageTemplate(self.GetMessage(CreateMessage(f.m_Destiny))), a_ParentTableName, a_ParentKeyFieldName, a_ParentPrefix, a_AccessFunc, keyboard, a_ButtonFunc, access_mode), a_StartCheckFunc) for i in range(len(fields) - 1): f = fields[i] next_f = fields[i + 1] - keyboard = bd_item.MixKeyboardFuncTemplate(self.AdditionalKeyboardForEditTemplate(next_f), GetKeyboard(next_f)) + keyboard = bd_item.MixKeyboardFuncTemplate(self.AdditionalKeyboardForEditTemplate(next_f, user_access.AccessMode.ADD), GetKeyboard(next_f)) self.m_Bot.RegisterMessageHandler(bd_item_add.NextAddBDItemTemplate(self.m_Bot, fsm, None, a_ParentTableName, a_ParentKeyFieldName, f.m_Name, self.ShowMessageTemplate(self.GetMessage(CreateMessage(next_f.m_Destiny))), None, a_AccessFunc, keyboard, a_ButtonFunc, access_mode, field_type = GetFieldType(f)), content_types = GetContentTypes(f), state = getattr(fsm, f'item{i}')) f_id = len(fields) - 1 diff --git a/bot_modules/subscribes.py b/bot_modules/subscribes.py index 84c2715..a807b8d 100644 --- a/bot_modules/subscribes.py +++ b/bot_modules/subscribes.py @@ -154,13 +154,6 @@ messages_subs_type_status = { messages.update(messages_subs_type_status) -def GetCurItemsTemplate(a_Bot, a_TableName, a_UserIDFieldName, a_StatusFieldName): - def GetBDItems(a_Message, a_UserGroups, a_ParentID): - user_id = str(a_Message.from_user.id) - request = f'SELECT * FROM {a_TableName} WHERE {a_UserIDFieldName} = ? AND {a_StatusFieldName} != ?' - return a_Bot.SQLRequest(request, param = ([user_id, str(OrderStatus.FINISH)])) - return GetBDItems - def GetBDItemsForUserTemplate(a_Bot, a_TableName, a_UserIDFieldName): def GetBDItems(a_Message, a_UserGroups, a_ParentID): user_id = str(a_Message.from_user.id) diff --git a/bot_sys/bd_table.py b/bot_sys/bd_table.py index b5b98d6..2af2e98 100644 --- a/bot_sys/bd_table.py +++ b/bot_sys/bd_table.py @@ -111,6 +111,13 @@ class Table: result = result.replace(f'#{f.m_Name}', str(a_BDItem[i])) return result + def ReplaceAllFieldTagsByDict(self, a_String, a_BDItemDict): + result = a_String + for f in self.m_Fields: + if f.m_Name in a_BDItemDict: + result = result.replace(f'#{f.m_Name}', str(a_BDItemDict[f.m_Name])) + return result + class Status(Enum): NEW = auto() FINISH = auto() diff --git a/template/bd_item.py b/template/bd_item.py index 5a08a84..8cc9783 100644 --- a/template/bd_item.py +++ b/template/bd_item.py @@ -100,7 +100,7 @@ def CheckAccessBDItemTemplate(a_Bot, a_TableName, a_KeyName, a_KeyValue, a_WorkF a_Bot.GetLog().Error(msg) return simple_message.WorkFuncResult(bot_messages.MakeBotMessage(msg)), None - result_work_func = await a_WorkFunc(a_CallbackQuery, item[0]) + result_work_func = await a_WorkFunc(a_CallbackQuery, item[0], None) if result_work_func is None or result_work_func.m_BotMessage is None: return result_work_func, result_work_func diff --git a/template/bd_item_add.py b/template/bd_item_add.py index 54c6960..e52ae4c 100644 --- a/template/bd_item_add.py +++ b/template/bd_item_add.py @@ -30,7 +30,7 @@ def StartAddBDItemTemplate(a_Bot, a_FSM, a_FSMStart, a_MessageFunc, a_ParentTabl if parent_id: check, res_of_work_func = await bd_item.CheckAccessBDItemTemplate(a_Bot, a_ParentTableName, a_ParentKeyFieldName, parent_id, a_MessageFunc, access_mode)(a_CallbackQuery) else: - res_of_work_func = await a_MessageFunc(a_CallbackQuery, None) + res_of_work_func = await a_MessageFunc(a_CallbackQuery, None, item_data) if not check is None: await state.finish() @@ -68,7 +68,7 @@ def FinishOrNextAddBDItemTemplate(a_Bot, a_FSM, a_AddBDItemFunc, a_ParentTableNa if parent_id: check, res_of_work_func = await bd_item.CheckAccessBDItemTemplate(a_Bot, a_ParentTableName, a_ParentKeyFieldName, parent_id, a_MessageFunc, access_mode)(a_Message) else: - res_of_work_func = await a_MessageFunc(a_Message, None) + res_of_work_func = await a_MessageFunc(a_Message, None, item_data) if not check is None: await state_func() From 2ada0a2508fbf23db15d507ef12d73a824c80ba1 Mon Sep 17 00:00:00 2001 From: Alexei Date: Sat, 14 Oct 2023 22:14:42 +0300 Subject: [PATCH 4/8] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth_docs/test_doc.odt | Bin 29149 -> 19082 bytes bot_modules/authorize.py | 20 +++++++++++++------- bot_modules/mod_table_operate.py | 4 ++-- template/docs_message.py | 25 +++++++++++++++---------- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/auth_docs/test_doc.odt b/auth_docs/test_doc.odt index abc5c88005da731bdb37a0bdef955abb781597ee..e937454b43901dd0f3ed5cac7cd085c9fedf03ee 100644 GIT binary patch literal 19082 zcmbTe1CVG>k}ur0ZsWFf`?hVnZ`-zQ+qP}nwr$(C&Da0gH}l2J&hEGSPQ;0*IFXr^ zS#?fUX4Nl`v=}f5G5`Ps0DxhNq>|?686pij|=U)#cyS4Xkz4G`!_Lm zbkz1%R_3}ow$%SSE<%Un48y&I!4W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}qUYeN?JtqPz?Ses^I~kF+lW8iq|1ZZcd#>PX`%X|jnumN z{<2Qu@iLW=M8^TmE5Z?#-69-SJjf$tbvJkvv7f2(=Csfg>`2Z7tl zU(kbG{*04RE1grF;Javst(gInM<^RkgKwTt5`3#rl1j#?bJJ%?w~!AP-7QQr^KuCD z2!C|oq}jtS3F&Zo8hH{PFxlbWQ7e;H&TWxKg+Bjip<9NUF;!a*{fY?O1VRmWlR@P2 z64#G5&rE44_n0;rNNs1jBl;k%eyRX(7t#I5N+yQsiZj+M^60DJs=LVP(Emj=h2u*DNfAT~V|2Yil!#G&iOvAe_=96OofzTdgGsWa@5dt4GN;9-)9Q2&H(W7Y z57tB=U4xD)!G*=Hk}yS1I>(+;|4h-8O?C+#NYbZE&FWp-{WtFVsFSbsfqEVxiDLwM z6Cs)H@9=*n(VVs*rN=09JXFp_Ejs6q5h=aFCo;_)dEul>kTW8H!ZchA~z;uq$F`iq%M@Sz0YEo ze0}0xSs!<&!VJETQU2Mu&1Mqg~l!EN}~kpH5u618scZa@CFo*8Cj z^*snTR45YATi)$q3tvP1a(Huf{X0|e9btWQb#Zb1@q5Gi?CN3s>&5W*?}*XEi;IVk uqtSPS@%i2Dcz8bk&QQL*dbs&Mm^?f`f0IC@W?Y-+^k-$h(;rQ^disC$bzZvw diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py index e7250d4..1e572d6 100644 --- a/bot_modules/authorize.py +++ b/bot_modules/authorize.py @@ -5,7 +5,7 @@ from bot_sys import bot_bd, keyboard, user_access, bd_table, bot_subscribes, config from bot_modules import mod_table_operate, mod_simple_message -from template import docs_message, bd_item +from template import docs_message, bd_item, bd_item_select from enum import Enum from enum import auto @@ -53,6 +53,7 @@ init_access = f'{user_access.user_access_group_new}=va' def GetAuthorizeItem(a_Bot, a_UserID): items = bd_item.GetBDItemsTemplate(a_Bot, table_name, user_id_field)(a_UserID) + print('GetAuthorizeItem', items) if len(items) == 1: return items[0] return None @@ -274,7 +275,7 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): assert fam_name_field_id != None assert access_field_id != None return \ - a_Item[name_field_id] + ' ' + a_Item[fam_name_field_id] + '(' + a_Item[key_name_id] +')',\ + a_Item[name_field_id] + ' ' + a_Item[fam_name_field_id] + '(' + str(a_Item[key_name_id]) +')',\ a_Item[key_name_id],\ a_Item[access_field_id] @@ -283,8 +284,9 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): user_id = str(a_Message.from_user.id) item = GetAuthorizeItem(self.m_Bot, user_id) user_confirm_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_CONFIRM) + print('GetStartKeyboardButtons', item, user_confirm_field_id) cur_buttons = [] - if item and item[user_confirm_field_id] == str(ConfirmStatus.YES): + if item and item[user_confirm_field_id] == self.GetMessage(mod_table_operate.EnumMessageForView(ConfirmStatus.YES)).GetDesc(): cur_buttons += [ keyboard.ButtonWithAccess(self.GetButton(ButtonNames.LIST_AUTH_DOCS), user_access.AccessMode.VIEW, self.GetAccess()), ] @@ -298,7 +300,8 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): cur_dict = GetReplaceDictFunc(self.m_Bot, a_user_id) result = {} for f in files: - result.update({f, cur_dict}) + result.update({f: cur_dict}) + print(cur_dict) return result button_name = self.GetButton(ButtonNames.LIST_AUTH_DOCS) @@ -323,18 +326,21 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): return super().AddBDItemFunc(a_ItemData, a_UserID) def GetReplaceDictFunc(a_Bot, a_user_id): - item = GetAuthorizeItem(self.m_Bot, user_id) + item = GetAuthorizeItem(a_Bot, a_user_id) if not item: return None result = {} i = 0 - for f in table: - result.update({str(f.m_Destiny), item[i]}) + for f in table.GetFields(): + result.update({str(f.m_Destiny): item[i]}) i += 1 + print(result) return result auth_docs_file_name = 'config_auth_docs' +g_auth_docs = [] + def GetAuthDocs(): global g_auth_docs if len(g_auth_docs) == 0: diff --git a/bot_modules/mod_table_operate.py b/bot_modules/mod_table_operate.py index 2fc8a8d..f826fc8 100644 --- a/bot_modules/mod_table_operate.py +++ b/bot_modules/mod_table_operate.py @@ -406,7 +406,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): ) def GetAddFields(self): - good_destiny = ( + add_destiny = ( bd_table.TableFieldDestiny.NAME, bd_table.TableFieldDestiny.DESC, bd_table.TableFieldDestiny.PHOTO, @@ -422,7 +422,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): ) fields = [] for f in self.m_Table.GetFields(): - if f.m_Destiny in good_destiny: + if f.m_Destiny in add_destiny: fields += [f] return fields diff --git a/template/docs_message.py b/template/docs_message.py index 7544125..e910632 100644 --- a/template/docs_message.py +++ b/template/docs_message.py @@ -6,7 +6,7 @@ from bot_sys import log, config, user_access from bot_modules import groups_utils from template import simple_message -import odf +#import odf def DocFilesTemplate(a_Bot, a_FilesFunc, a_CaptionMessage, a_AccessFunc, a_GetButtonsFunc, a_GetInlineButtonsFunc, a_ErrorMessage, access_mode = user_access.AccessMode.EDIT): async def DocFiles(a_Message): @@ -23,11 +23,11 @@ def DocFilesTemplate(a_Bot, a_FilesFunc, a_CaptionMessage, a_AccessFunc, a_GetBu await simple_message.SendMessage(a_Bot, a_ErrorMessage, a_GetButtonsFunc, None, user_id, a_Message, user_groups) return - for file_path, dict_replace in files.values(): + for file_path, dict_replace in files.items(): if not dict_replace: continue new_file = await MakeDocFile(a_Bot, file_path, dict_replace, user_id) - document = await GetFile(a_Bot, file_path) + document = await GetFile(a_Bot, new_file) if document is None: await simple_message.SendMessage(a_Bot, a_ErrorMessage, a_GetButtonsFunc, None, user_id, a_Message, user_groups) else: @@ -40,20 +40,25 @@ def DocFilesTemplate(a_Bot, a_FilesFunc, a_CaptionMessage, a_AccessFunc, a_GetBu ) return DocFiles +from odf import opendocument, text, teletype + async def MakeDocFile(a_Bot, a_FilePath, a_DictReplace, a_user_id): - document = odf.opendocument.load(a_FilePath) + print ('MakeDocFile', a_FilePath) + #FixBadZipfile(a_FilePath) + document = opendocument.load(a_FilePath) # odf.opendocuement. if document == None: a_Bot.GetLog().Error(f'Не удалось загрузить файл {a_FilePath}.') return None for element in document.getElementsByType(text.Span): - extracted_text = odf.teletype.extractText(element) + extracted_text = teletype.extractText(element) + print('MakeDocFile', extracted_text) - for file_path, dict_replace in a_DictReplace.values(): - if extracted_text.find('Replace this') != -1: - extracted_text = extracted_text.replace('Replace this', 'to this') + for rep_this, to_this in a_DictReplace.items(): + if extracted_text.find(rep_this) != -1: + extracted_text = extracted_text.replace(rep_this, to_this) - new_element = odf.text.Span() + new_element = text.Span() new_element.setAttribute('stylename', element.getAttribute('stylename')) new_element.addText(extracted_text) @@ -61,7 +66,7 @@ async def MakeDocFile(a_Bot, a_FilePath, a_DictReplace, a_user_id): element.parentNode.removeChild(element) new_file_path = a_FilePath[:-4] - new_file_path += f"{a_user_id}.odt" + new_file_path += f"_{a_user_id}.odt" document.save(new_file_path) return new_file_path From 3e6d3a5ec5f1167c6fc48280a3e8d7be2eb09f82 Mon Sep 17 00:00:00 2001 From: Alexei Date: Tue, 31 Oct 2023 15:52:31 +0300 Subject: [PATCH 5/8] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BD=D0=B0=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8?= =?UTF-8?q?=D0=BE=D1=82=D0=B5=D0=BA=D1=83=20weasyprint=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth_docs/test_doc.html | 120 +++++++++++++++++++++++++++++++++++++++++++++++ auth_docs/test_doc.odt | Bin 19082 -> 18549 bytes bot_modules/authorize.py | 2 +- config_auth_docs | 2 +- requirements.txt | 2 +- template/docs_message.py | 60 +++++++++++++++--------- 6 files changed, 160 insertions(+), 26 deletions(-) create mode 100644 auth_docs/test_doc.html diff --git a/auth_docs/test_doc.html b/auth_docs/test_doc.html new file mode 100644 index 0000000..3f326bf --- /dev/null +++ b/auth_docs/test_doc.html @@ -0,0 +1,120 @@ + + + + + + + + + + +

+
+ +

+

Регистрационные +данные

+


+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ ID пользователя

+

+ TableFieldDestiny.USER_ID +

+

+ Имя

+

+ TableFieldDestiny.USER_NAME

+

+ Фамилия

+

+ TableFieldDestiny.USER_FAMILY_NAME

+

+ Отчество

+

+ TableFieldDestiny.USER_MIDDLE_NAME

+

+ Дата рождения

+

+ TableFieldDestiny.USER_BIRTHDAY

+

+ Адрес

+

+ TableFieldDestiny.USER_ADDRESS

+

+ Контакты

+

+ TableFieldDestiny.USER_CONTACTS

+

+ Подтверждение

+

+ TableFieldDestiny.USER_CONFIRM

+

+ Доступ

+

+ TableFieldDestiny.ACCESS

+

+ Дата создания записи

+

+ TableFieldDestiny.CREATE_DATE

+
+


+ +

+ + \ No newline at end of file diff --git a/auth_docs/test_doc.odt b/auth_docs/test_doc.odt index e937454b43901dd0f3ed5cac7cd085c9fedf03ee..92fa308fe04a9cd84a49e5d9c1399e8794930fb5 100644 GIT binary patch delta 16620 zcmbum1#})gvLQ+mtD%De=381&ppa}9(;1FmaAkZKnVMaPJ2$JA`l4znB50rmUO#jS? zLllFB`?sobzd(uN@IcZ26vq|3(-~qP|9|CC|0-wutKKhAmcLRgFwQ?|?N=~vP~e?V z1^Kt@{ZT-yj2!i7U9Bu5lt!#q=#kp)zreGqhUDdGFc5v=N94&j_2J~V`5H`7&EykxCU0SW4)MM5Zx4yJ0&05-lIB< z?sRYk=xOc;?hSZA@l?$yzwG|t#A}59>^JY(%;F*}g@0aCcdQ3~JLLgijtE2OeNk=d z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4X;JGxgL=4l3d~65k5EcYz2W|@no{I!N zk_BBC@@8aI`|?>)5BPxT#I;!&Vc&V6LAbUq!%Ts>8oAX58hb$iHw)yE7<7Heg)XQ~ phX860C@nm6jmV`3s7ywH`7St0=m2k4HjpwwAWQ`oI{a=R9ss&SMn3=m diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py index 1e572d6..9c39865 100644 --- a/bot_modules/authorize.py +++ b/bot_modules/authorize.py @@ -332,7 +332,7 @@ def GetReplaceDictFunc(a_Bot, a_user_id): result = {} i = 0 for f in table.GetFields(): - result.update({str(f.m_Destiny): item[i]}) + result.update({str(f.m_Destiny): str(item[i])}) i += 1 print(result) return result diff --git a/config_auth_docs b/config_auth_docs index 7822470..1524400 100644 --- a/config_auth_docs +++ b/config_auth_docs @@ -1 +1 @@ -auth_docs/test_doc.odt +auth_docs/test_doc.html diff --git a/requirements.txt b/requirements.txt index 9e91223..296c19c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ aiogram==2.20 colorama==0.4.5 -odfpy +weasyprint diff --git a/template/docs_message.py b/template/docs_message.py index e910632..3f9288a 100644 --- a/template/docs_message.py +++ b/template/docs_message.py @@ -40,35 +40,49 @@ def DocFilesTemplate(a_Bot, a_FilesFunc, a_CaptionMessage, a_AccessFunc, a_GetBu ) return DocFiles -from odf import opendocument, text, teletype +async def ReplaceInFile(a_Bot, a_InputFileName, a_OutFileName, a_DictReplace): + try: + filedata = '' + print('ReplaceInFile f', a_InputFileName) + with open(a_InputFileName, 'r') as in_f: + filedata = in_f.read() -async def MakeDocFile(a_Bot, a_FilePath, a_DictReplace, a_user_id): - print ('MakeDocFile', a_FilePath) - #FixBadZipfile(a_FilePath) - document = opendocument.load(a_FilePath) # odf.opendocuement. - if document == None: - a_Bot.GetLog().Error(f'Не удалось загрузить файл {a_FilePath}.') - return None + s = filedata + print('ReplaceInFile s', s) + for rep_this, to_this in a_DictReplace.items(): + print('ReplaceInFile', rep_this, to_this) + s = s.replace(rep_this, to_this) - for element in document.getElementsByType(text.Span): - extracted_text = teletype.extractText(element) - print('MakeDocFile', extracted_text) + with open(a_OutFileName, 'w') as out_f: + out_f.write(s) + a_Bot.GetLog().Success(f'Создан файл {a_OutFileName}') + return a_OutFileName + except Exception as e: + a_Bot.GetLog().Error(f'Не удалось заменить текст в фале {a_InputFileName} и записать в {a_OutFileName}. Ошибка {str(e)}') + return None - for rep_this, to_this in a_DictReplace.items(): - if extracted_text.find(rep_this) != -1: - extracted_text = extracted_text.replace(rep_this, to_this) +from weasyprint import HTML, CSS - new_element = text.Span() - new_element.setAttribute('stylename', element.getAttribute('stylename')) - new_element.addText(extracted_text) +async def SaveAsPdf(a_Bot, a_InputFileName, a_OutFileName): + try: + HTML(filename = a_InputFileName).write_pdf(a_OutFileName) + a_Bot.GetLog().Success(f'Создан файл {a_OutFileName}') + return a_OutFileName + except Exception as e: + a_Bot.GetLog().Error(f'Не удалось создать пдф из фала {a_InputFileName} и записать в {a_OutFileName}. Ошибка {str(e)}') + return None - element.parentNode.insertBefore(new_element, element) - element.parentNode.removeChild(element) +async def MakeDocFile(a_Bot, a_FilePath, a_DictReplace, a_user_id): + print ('MakeDocFile', a_FilePath) + user_file_path = a_FilePath[:-5] + pdf_file_path = user_file_path + user_file_path += f"_{a_user_id}.html" + pdf_file_path += f"_{a_user_id}.pdf" + user_file_path = await ReplaceInFile(a_Bot, a_FilePath, user_file_path, a_DictReplace) + if not user_file_path: + return None - new_file_path = a_FilePath[:-4] - new_file_path += f"_{a_user_id}.odt" - document.save(new_file_path) - return new_file_path + return await SaveAsPdf(a_Bot, user_file_path, pdf_file_path) async def GetFile(a_Bot, a_Path): if not a_Path: From 6c67b2e3e641b12c50db0ace3aa36fd937e813dd Mon Sep 17 00:00:00 2001 From: Alexei Date: Sat, 4 Nov 2023 13:08:45 +0300 Subject: [PATCH 6/8] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9=201.=20=D0=9A=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=B7=D0=B0=D1=8F=D0=B2=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=83=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D1=82=D1=81=D1=8F=202.?= =?UTF-8?q?=20=D0=9F=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=B7=D0=B0=D1=8F=D0=B2=D0=BA=D0=B8=20=D0=B4?= =?UTF-8?q?=D1=80=D1=83=D0=B3=D0=B8=D1=85=20=D0=BD=D0=B5=20=D0=B2=D0=B8?= =?UTF-8?q?=D0=B4=D0=BD=D1=8B=203.=20=D0=9D=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot_modules/access.py | 2 +- bot_modules/all_orders.py | 2 +- bot_modules/authorize.py | 37 +++++++++++++++++++-------- bot_modules/backup.py | 2 +- bot_modules/bd_version.py | 2 +- bot_modules/buttons.py | 2 +- bot_modules/comments.py | 2 +- bot_modules/groups.py | 4 +-- bot_modules/groups_utils.py | 6 ++++- bot_modules/languages.py | 2 +- bot_modules/messages.py | 2 +- bot_modules/mod_simple_message.py | 5 ++-- bot_modules/mod_table_operate.py | 48 +++++++++++++++++++++++------------ bot_modules/needs.py | 2 +- bot_modules/orders.py | 6 ++--- bot_modules/profile.py | 2 +- bot_modules/projects.py | 2 +- bot_modules/start.py | 2 +- bot_modules/subscribes.py | 6 ++--- bot_modules/tasks.py | 2 +- bot_modules/user_in_groups.py | 2 +- bot_modules/users.py | 2 +- bot_modules/users_groups_agregator.py | 9 ++++++- template/docs_message.py | 7 ++--- 24 files changed, 100 insertions(+), 58 deletions(-) diff --git a/bot_modules/access.py b/bot_modules/access.py index c5b9b6b..da020e4 100644 --- a/bot_modules/access.py +++ b/bot_modules/access.py @@ -106,7 +106,7 @@ init_access = f'{user_access.user_access_group_new}=-' class ModuleAccess(mod_table_operate.TableOperateModule): def __init__(self, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, None, None, init_access, a_ChildModuleNameList, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, None, None, init_access, init_access, a_ChildModuleNameList, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) self.m_SqlRequestButtonName = self.CreateButton('sql request', sql_request_button_name) self.m_RequestStartMessage = self.CreateMessage('equest start', request_start_message) diff --git a/bot_modules/all_orders.py b/bot_modules/all_orders.py index 5efd31f..9f40bb9 100644 --- a/bot_modules/all_orders.py +++ b/bot_modules/all_orders.py @@ -111,7 +111,7 @@ class DBItemForUserSelectSource(bd_item_select.DBItemSelectSource): class ModuleAllOrders(orders.ModuleOrders): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetInitBDCommands(self): # уже сделано в ModuleUserOrders diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py index 9c39865..cc9f9e3 100644 --- a/bot_modules/authorize.py +++ b/bot_modules/authorize.py @@ -4,7 +4,7 @@ # Авторизация или регистрация в кооперативе или другой организации from bot_sys import bot_bd, keyboard, user_access, bd_table, bot_subscribes, config -from bot_modules import mod_table_operate, mod_simple_message +from bot_modules import mod_table_operate, mod_simple_message, users_groups_agregator, groups_utils from template import docs_message, bd_item, bd_item_select from enum import Enum @@ -50,6 +50,8 @@ table = bd_table.Table(table_name, [ ) init_access = f'{user_access.user_access_group_new}=va' +def_init_access = f'{user_access.user_access_group_new}=a' +g_group_auth_name = 'authorize_users' def GetAuthorizeItem(a_Bot, a_UserID): items = bd_item.GetBDItemsTemplate(a_Bot, table_name, user_id_field)(a_UserID) @@ -246,7 +248,7 @@ messages.update(messages_confirm_status) class ModuleAuthorize(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, def_init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name @@ -279,18 +281,23 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): a_Item[key_name_id],\ a_Item[access_field_id] - def GetStartKeyboardButtons(self, a_Message, a_UserGroups): - parent_buttons = super().GetStartKeyboardButtons(a_Message, a_UserGroups) + def GetStartButtons(self, a_Message, a_UserGroups): user_id = str(a_Message.from_user.id) item = GetAuthorizeItem(self.m_Bot, user_id) user_confirm_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_CONFIRM) - print('GetStartKeyboardButtons', item, user_confirm_field_id) + cur_buttons = [] + if item and item[user_confirm_field_id] == self.GetMessage(mod_table_operate.EnumMessageForView(ConfirmStatus.YES)).GetDesc(): - cur_buttons += [ - keyboard.ButtonWithAccess(self.GetButton(ButtonNames.LIST_AUTH_DOCS), user_access.AccessMode.VIEW, self.GetAccess()), - ] - return parent_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) + cur_buttons += [[ButtonNames.LIST_AUTH_DOCS, user_access.AccessMode.VIEW]] + else: + cur_buttons += [[mod_table_operate.ButtonNames.ADD, user_access.AccessMode.ADD]] + + return cur_buttons + [ + [mod_table_operate.ButtonNames.LIST, user_access.AccessMode.VIEW], + [mod_table_operate.ButtonNames.DEL, user_access.AccessMode.DELETE], + [mod_table_operate.ButtonNames.EDIT, user_access.AccessMode.EDIT], + ] def RegisterHandlers(self): super().RegisterHandlers() @@ -323,7 +330,17 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): def AddBDItemFunc(self, a_ItemData, a_UserID): a_ItemData[user_id_field] = a_UserID #a_ItemData[address_field] = '' - return super().AddBDItemFunc(a_ItemData, a_UserID) + result = super().AddBDItemFunc(a_ItemData, a_UserID) + users_groups_agregator.AddUserInGroup(self.m_Bot, a_UserID, g_group_auth_name) + return result + + def GetKeyFieldDestiny(self): + return bd_table.TableFieldDestiny.USER_ID + + def GetInitBDCommands(self): + return super(). GetInitBDCommands() + [ + groups_utils.CreateGroupRequest(g_group_auth_name) + ] def GetReplaceDictFunc(a_Bot, a_user_id): item = GetAuthorizeItem(a_Bot, a_user_id) diff --git a/bot_modules/backup.py b/bot_modules/backup.py index cf294a2..dc7b989 100644 --- a/bot_modules/backup.py +++ b/bot_modules/backup.py @@ -48,7 +48,7 @@ init_access = f'{user_access.user_access_group_new}=-' class ModuleBackup(mod_simple_message.SimpleMessageModule): def __init__(self, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(messages, button_names, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(messages, button_names, init_access, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) self.m_BackupBDButtonName = self.CreateButton('backup bd', backup_bd_button_name) self.m_BackupBDMessage = self.CreateMessage('backup bd', backup_bd_message) diff --git a/bot_modules/bd_version.py b/bot_modules/bd_version.py index d74dfd9..081a075 100644 --- a/bot_modules/bd_version.py +++ b/bot_modules/bd_version.py @@ -40,7 +40,7 @@ messages = { class ModuleBDVersion(mod_table_operate.TableOperateModule): def __init__(self, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, None, None, init_access, None, None, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, None, None, init_access, init_access, None, None, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/buttons.py b/bot_modules/buttons.py index 63e77fa..09dbfda 100644 --- a/bot_modules/buttons.py +++ b/bot_modules/buttons.py @@ -128,7 +128,7 @@ messages = { class ModuleButtons(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/comments.py b/bot_modules/comments.py index 953169f..b5c8457 100644 --- a/bot_modules/comments.py +++ b/bot_modules/comments.py @@ -130,7 +130,7 @@ messages.update(messages_subscribes) class ModuleComments(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/groups.py b/bot_modules/groups.py index c82485c..4e10654 100644 --- a/bot_modules/groups.py +++ b/bot_modules/groups.py @@ -125,12 +125,12 @@ messages = { class ModuleGroups(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name def GetInitBDCommands(self): return super(). GetInitBDCommands() + [ - f"INSERT OR IGNORE INTO {table_name} ({name_field}, {access_field}, {create_datetime_field}) VALUES ('{user_access.user_access_group_new}', '{user_access.user_access_group_new}=-', {bot_bd.GetBDDateTimeNow()});" + groups_utils.CreateGroupRequest(user_access.user_access_group_new) ] diff --git a/bot_modules/groups_utils.py b/bot_modules/groups_utils.py index 1bc67a0..27b2bbe 100644 --- a/bot_modules/groups_utils.py +++ b/bot_modules/groups_utils.py @@ -3,7 +3,7 @@ # Группы пользователей -from bot_sys import user_access +from bot_sys import user_access, bot_bd table_name = 'user_groups' key_name = 'groupID' @@ -28,3 +28,7 @@ def GetUserGroupData(a_Bot, a_UserID): if len(i) > 0: groups += [i[0]] return user_access.UserGroups(a_UserID, groups) + +def CreateGroupRequest(a_GroupName): + return f"INSERT OR IGNORE INTO {table_name} ({name_field}, {access_field}, {create_datetime_field}) VALUES ('{a_GroupName}', '{user_access.user_access_group_new}=-', {bot_bd.GetBDDateTimeNow()});" + diff --git a/bot_modules/languages.py b/bot_modules/languages.py index 06d0835..b3022fb 100644 --- a/bot_modules/languages.py +++ b/bot_modules/languages.py @@ -126,7 +126,7 @@ messages = { class ModuleLanguages(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) self.m_LanguageIDs = {} def GetName(self): diff --git a/bot_modules/messages.py b/bot_modules/messages.py index 310b043..27ca51f 100644 --- a/bot_modules/messages.py +++ b/bot_modules/messages.py @@ -128,7 +128,7 @@ messages = { class ModuleMessages(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/mod_simple_message.py b/bot_modules/mod_simple_message.py index a533a9d..8f5e9a3 100644 --- a/bot_modules/mod_simple_message.py +++ b/bot_modules/mod_simple_message.py @@ -17,9 +17,10 @@ class Messages(Enum): START = auto() class SimpleMessageModule(mod_interface.IModule): - def __init__(self, a_Messages, a_Buttons, a_InitAccess, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): + def __init__(self, a_Messages, a_Buttons, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): self.m_ChildModuleNameList = a_ChildModuleNameList self.m_InitAccess = a_InitAccess + self.m_DefInitAccess = a_DefInitAccess self.m_Bot = a_Bot self.m_ModuleAgregator = a_ModuleAgregator self.m_BotMessages = a_BotMessages @@ -99,7 +100,7 @@ class SimpleMessageModule(mod_interface.IModule): def GetInitBDCommands(self): return [ - access_utils.GetAccessForModuleRequest(self.GetName(), self.m_InitAccess, self.m_InitAccess), + access_utils.GetAccessForModuleRequest(self.GetName(), self.m_InitAccess, self.m_DefInitAccess), ] def GetAccess(self): diff --git a/bot_modules/mod_table_operate.py b/bot_modules/mod_table_operate.py index f826fc8..5c257c4 100644 --- a/bot_modules/mod_table_operate.py +++ b/bot_modules/mod_table_operate.py @@ -83,8 +83,8 @@ def MakeFSMForEdit(a_ModName, a_FieldName): return _locals['fsm'] class TableOperateModule(mod_simple_message.SimpleMessageModule): - def __init__(self, a_Table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(a_Messages, a_Buttons, a_InitAccess, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + def __init__(self, a_Table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): + super().__init__(a_Messages, a_Buttons, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) self.m_Table = a_Table self.m_EditModuleNameList = a_EditModuleNameList self.m_ChildModName = a_ChildModName @@ -99,8 +99,8 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): return self.GetButtonNameAndKeyValueAndAccess(a_Item) self.m_GetButtonNameAndKeyValueAndAccessFunc = GetButtonNameAndKeyValueAndAccess - async def PreDelete(a_CallbackQuery, a_Item): - return await self.PreDelete(a_CallbackQuery, a_Item) + async def PreDelete(a_CallbackQuery, a_Item, a_None): + return await self.PreDelete(a_CallbackQuery, a_Item, a_None) self.m_PreDeleteFunc = PreDelete async def PostDelete(a_CallbackQuery, a_ItemID): @@ -116,14 +116,21 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): self.m_Table.GetInitTableRequest(), ] + super().GetInitBDCommands() + def GetStartButtons(self, a_Message, a_UserGroups): + return [ + [ButtonNames.LIST, user_access.AccessMode.VIEW], + [ButtonNames.ADD, user_access.AccessMode.ADD], + [ButtonNames.DEL, user_access.AccessMode.DELETE], + [ButtonNames.EDIT, user_access.AccessMode.EDIT], + ] + def GetStartKeyboardButtons(self, a_Message, a_UserGroups): mod_buttons = super().GetStartKeyboardButtons(a_Message, a_UserGroups) - cur_buttons = [ - keyboard.ButtonWithAccess(self.GetButton(ButtonNames.LIST), user_access.AccessMode.VIEW, self.GetAccess()), - keyboard.ButtonWithAccess(self.GetButton(ButtonNames.ADD), user_access.AccessMode.ADD, self.GetAccess()), - keyboard.ButtonWithAccess(self.GetButton(ButtonNames.DEL), user_access.AccessMode.DELETE, self.GetAccess()), - keyboard.ButtonWithAccess(self.GetButton(ButtonNames.EDIT), user_access.AccessMode.EDIT, self.GetAccess()), - ] + cur_buttons = [] + for b in self.GetStartButtons(a_Message, a_UserGroups): + bn = b[0] + ba = b[1] + cur_buttons += [keyboard.ButtonWithAccess(self.GetButton(bn), ba, self.GetAccess())] return mod_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) def GetAccessForEditKeyboardButtons(self, a_Field): @@ -157,7 +164,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): return keyboard.MakeInlineKeyboardButtons(self.m_Bot, cur_buttons, a_UserGroups) def GetButtonNameAndKeyValueAndAccess(self, a_Item): - key_name_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.KEY) + key_name_id = self.GetKeyFieldID() name_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.NAME) access_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.ACCESS) assert key_name_id != None @@ -220,12 +227,12 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): msg = self.UpdateMessage(msg, lang, a_Item, a_EnablePhoto = a_EnablePhoto) item_access = a_Item[self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.ACCESS)] if Inline_keyboard_template_func: - Inline_keyboard_func = Inline_keyboard_template_func(a_Item[self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.KEY)]) + Inline_keyboard_func = Inline_keyboard_template_func(a_Item[self.GetKeyFieldID()]) return simple_message.WorkFuncResult(msg, item_access = item_access, Inline_keyboard_func = Inline_keyboard_func) return ShowMessage - async def PreDelete(self, a_CallbackQuery, a_Item): + async def PreDelete(self, a_CallbackQuery, a_Item, a_None): if len(a_Item) < self.m_Table.GetFieldsCount(): return simple_message.WorkFuncResult(self.GetMessage(Messages.ERROR_FIND)) access = a_Item[self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.ACCESS)] @@ -379,7 +386,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): return self.OnChange() table_name = self.m_Table.GetName() - key_name = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.KEY) + key_name = self.GetKeyFieldName() edit_keyboard_func = self.m_GetEditKeyboardButtonsFunc GetButtonNameAndKeyValueAndAccess = self.m_GetButtonNameAndKeyValueAndAccessFunc GetAccess = self.m_GetAccessFunc @@ -469,10 +476,19 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): f = fields[f_id] self.m_Bot.RegisterMessageHandler(bd_item_add.FinishAddBDItemTemplate(self.m_Bot, fsm, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, f.m_Name, self.ShowMessageTemplate(self.GetMessage(Messages.SUCCESS_CREATE)), None, a_AccessFunc, a_ButtonFunc, access_mode, field_type = GetFieldType(f)), content_types = GetContentTypes(f), state = getattr(fsm, f'item{f_id}')) + def GetKeyFieldDestiny(self): + return bd_table.TableFieldDestiny.KEY + + def GetKeyFieldName(self): + return self.m_Table.GetFieldNameByDestiny(self.GetKeyFieldDestiny()) + + def GetKeyFieldID(self): + return self.m_Table.GetFieldIDByDestiny(self.GetKeyFieldDestiny()) + def RegisterHandlers(self): super().RegisterHandlers() table_name = self.m_Table.GetName() - key_name = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.KEY) + key_name = self.GetKeyFieldName() name_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.NAME) desc_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.DESC) photo_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PHOTO) @@ -485,7 +501,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): if self.m_ParentModName: parent_mod = self.GetModule(self.m_ParentModName) parent_table_name = parent_mod.m_Table.GetName() - parent_key_name = parent_mod.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.KEY) + parent_key_name = parent_mod.GetKeyFieldName() def GetViewItemInlineKeyboardTemplate(a_ItemID): return self.GetViewItemInlineKeyboardTemplate(a_ItemID) diff --git a/bot_modules/needs.py b/bot_modules/needs.py index 0f0bf2f..ace1d88 100644 --- a/bot_modules/needs.py +++ b/bot_modules/needs.py @@ -131,7 +131,7 @@ messages.update(messages_subscribes) class ModuleNeeds(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/orders.py b/bot_modules/orders.py index 3559006..edf6fd0 100644 --- a/bot_modules/orders.py +++ b/bot_modules/orders.py @@ -200,8 +200,8 @@ class DBItemForUserSelectSource(bd_item_select.DBItemSelectSource): return True class ModuleOrders(mod_table_operate.TableOperateModule): - def __init__(self, a_Table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + def __init__(self, a_Table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): + super().__init__(table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def SelectSourceTemplate(self, a_PrevPrefix, a_ButtonName): parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID) @@ -262,7 +262,7 @@ class ModuleOrders(mod_table_operate.TableOperateModule): class ModuleUserOrders(ModuleOrders): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/profile.py b/bot_modules/profile.py index f0c2a67..c584a07 100644 --- a/bot_modules/profile.py +++ b/bot_modules/profile.py @@ -32,7 +32,7 @@ init_access = f'{user_access.user_access_group_new}=+' class ModuleProfile(mod_simple_message.SimpleMessageModule): def __init__(self, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(messages, button_names, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(messages, button_names, init_access, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/projects.py b/bot_modules/projects.py index becbc93..a3fc0c0 100644 --- a/bot_modules/projects.py +++ b/bot_modules/projects.py @@ -129,7 +129,7 @@ messages.update(messages_subscribes) class ModuleProjects(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/start.py b/bot_modules/start.py index dc55776..58d3c63 100644 --- a/bot_modules/start.py +++ b/bot_modules/start.py @@ -24,7 +24,7 @@ init_access = f'{user_access.user_access_group_all}=+' class ModuleStart(mod_simple_message.SimpleMessageModule): def __init__(self, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(messages, button_names, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(messages, button_names, init_access, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/subscribes.py b/bot_modules/subscribes.py index a807b8d..6c4e663 100644 --- a/bot_modules/subscribes.py +++ b/bot_modules/subscribes.py @@ -171,8 +171,8 @@ class DBItemForUserSelectSource(bd_item_select.DBItemSelectSource): return True class ModuleSubscribe(mod_table_operate.TableOperateModule): - def __init__(self, a_Table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + def __init__(self, a_Table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): + super().__init__(table, a_Messages, a_Buttons, a_ParentModName, a_ChildModName, a_InitAccess, a_DefInitAccess, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def SelectSourceTemplate(self, a_PrevPrefix, a_ButtonName): parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID) @@ -205,7 +205,7 @@ class ModuleSubscribe(mod_table_operate.TableOperateModule): class ModuleUserSubscribe(ModuleSubscribe): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) self.UpdateSubscribes() def GetName(self): diff --git a/bot_modules/tasks.py b/bot_modules/tasks.py index 8e148b7..1523adb 100644 --- a/bot_modules/tasks.py +++ b/bot_modules/tasks.py @@ -131,7 +131,7 @@ messages.update(messages_subscribes) class ModuleTasks(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/user_in_groups.py b/bot_modules/user_in_groups.py index f2e7830..3509cad 100644 --- a/bot_modules/user_in_groups.py +++ b/bot_modules/user_in_groups.py @@ -106,7 +106,7 @@ messages = { class ModuleUserInGroups(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/users.py b/bot_modules/users.py index e4feaee..ba92907 100644 --- a/bot_modules/users.py +++ b/bot_modules/users.py @@ -128,7 +128,7 @@ messages = { class ModuleUsers(mod_table_operate.TableOperateModule): def __init__(self, a_ParentModName, a_ChildModName, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(table, messages, button_names, a_ParentModName, a_ChildModName, init_access, init_access, a_ChildModuleNameList, a_EditModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) def GetName(self): return module_name diff --git a/bot_modules/users_groups_agregator.py b/bot_modules/users_groups_agregator.py index 4c4533a..7c29fe7 100644 --- a/bot_modules/users_groups_agregator.py +++ b/bot_modules/users_groups_agregator.py @@ -57,7 +57,7 @@ init_access = f'{user_access.user_access_group_new}=-' class ModuleUsersGroupsAgregator(mod_simple_message.SimpleMessageModule): def __init__(self, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log): - super().__init__(messages, button_names, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) + super().__init__(messages, button_names, init_access, init_access, a_ChildModuleNameList, a_Bot, a_ModuleAgregator, a_BotMessages, a_BotButtons, a_BotSubscribes, a_Log) self.m_SqlRequestButtonName = self.CreateButton('sql request', sql_request_button_name) self.m_RequestStartMessage = self.CreateMessage('equest start', request_start_message) @@ -99,3 +99,10 @@ class ModuleUsersGroupsAgregator(mod_simple_message.SimpleMessageModule): bd_item.GetCheckForTextFunc(self.m_HelpButtonName) ) +def AddUserInGroup(a_Bot, a_UserID, a_GroupName): + g_id = a_Bot.SQLRequest(f'SELECT {groups.key_name} FROM {groups.table_name} WHERE {groups.name_field} = "{a_GroupName}"'); + print ('AddUserInGroup', g_id) + if not g_id or len(g_id) != 1 or len(g_id[0]) != 1: + return False + group_id = g_id[0][0] + a_Bot.SQLRequest(f'INSERT INTO {user_in_groups.table_name}({user_in_groups.name_field}, {user_in_groups.parent_id_field}) VALUES({a_UserID}, {group_id})') diff --git a/template/docs_message.py b/template/docs_message.py index 3f9288a..9354644 100644 --- a/template/docs_message.py +++ b/template/docs_message.py @@ -43,14 +43,12 @@ def DocFilesTemplate(a_Bot, a_FilesFunc, a_CaptionMessage, a_AccessFunc, a_GetBu async def ReplaceInFile(a_Bot, a_InputFileName, a_OutFileName, a_DictReplace): try: filedata = '' - print('ReplaceInFile f', a_InputFileName) + with open(a_InputFileName, 'r') as in_f: filedata = in_f.read() - s = filedata - print('ReplaceInFile s', s) + for rep_this, to_this in a_DictReplace.items(): - print('ReplaceInFile', rep_this, to_this) s = s.replace(rep_this, to_this) with open(a_OutFileName, 'w') as out_f: @@ -73,7 +71,6 @@ async def SaveAsPdf(a_Bot, a_InputFileName, a_OutFileName): return None async def MakeDocFile(a_Bot, a_FilePath, a_DictReplace, a_user_id): - print ('MakeDocFile', a_FilePath) user_file_path = a_FilePath[:-5] pdf_file_path = user_file_path user_file_path += f"_{a_user_id}.html" From 6c78244efae7680889eeb13a11caf9e8c84648be Mon Sep 17 00:00:00 2001 From: Alexei Date: Sat, 4 Nov 2023 13:31:56 +0300 Subject: [PATCH 7/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20=D0=B2=20=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=BF=D0=BF=D1=83=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot_modules/users_groups_agregator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot_modules/users_groups_agregator.py b/bot_modules/users_groups_agregator.py index 7c29fe7..e26b55d 100644 --- a/bot_modules/users_groups_agregator.py +++ b/bot_modules/users_groups_agregator.py @@ -101,8 +101,10 @@ class ModuleUsersGroupsAgregator(mod_simple_message.SimpleMessageModule): def AddUserInGroup(a_Bot, a_UserID, a_GroupName): g_id = a_Bot.SQLRequest(f'SELECT {groups.key_name} FROM {groups.table_name} WHERE {groups.name_field} = "{a_GroupName}"'); - print ('AddUserInGroup', g_id) if not g_id or len(g_id) != 1 or len(g_id[0]) != 1: return False group_id = g_id[0][0] - a_Bot.SQLRequest(f'INSERT INTO {user_in_groups.table_name}({user_in_groups.name_field}, {user_in_groups.parent_id_field}) VALUES({a_UserID}, {group_id})') + r = f'INSERT OR IGNORE INTO {user_in_groups.table_name}({user_in_groups.name_field}, {user_in_groups.parent_id_field}) VALUES(?, ?)' + result = a_Bot.SQLRequest(r, commit=True, param = (a_UserID, group_id)) + + From 423acd9fadae093f6bf8b4749f9a6c58453711b9 Mon Sep 17 00:00:00 2001 From: Alexei Date: Sat, 4 Nov 2023 14:46:45 +0300 Subject: [PATCH 8/8] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9=20#9=201.=20=D0=97?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D0=B4=D0=BE=D0=BA?= =?UTF-8?q?=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B8=20=D1=87?= =?UTF-8?q?=D0=B5=D0=BA=D0=B0=20=D0=BE=D0=B1=20=D0=BE=D0=BF=D0=BB=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=20=D0=A7=D0=92=202.=20=D0=97=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D1=8B=20=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=BD=D1=8B?= =?UTF-8?q?=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot_modules/authorize.py | 42 ++++++++++++++++++++++++++++++++++-------- bot_modules/orders.py | 2 +- bot_sys/bd_table.py | 1 + bot_sys/user_access.py | 2 ++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/bot_modules/authorize.py b/bot_modules/authorize.py index cc9f9e3..dced8b2 100644 --- a/bot_modules/authorize.py +++ b/bot_modules/authorize.py @@ -22,6 +22,8 @@ user_birthday_field = 'userBirthday' user_address_field = 'userAddress' user_contacts_field = 'userContacts' user_confirm_field = 'userConfirm' +user_auth_docs_field = 'authDocs' +user_photo_pay_field = 'photoPay' access_field = 'authorizeAccess' create_datetime_field = 'authorizeCreateDateTime' @@ -40,6 +42,8 @@ table = bd_table.Table(table_name, [ bd_table.TableField(user_address_field, bd_table.TableFieldDestiny.USER_ADDRESS, bd_table.TableFieldType.STR), bd_table.TableField(user_contacts_field, bd_table.TableFieldDestiny.USER_CONTACTS, bd_table.TableFieldType.STR), bd_table.TableField(user_confirm_field, bd_table.TableFieldDestiny.USER_CONFIRM, bd_table.TableFieldType.ENUM, a_Enum = ConfirmStatus), + bd_table.TableField(user_auth_docs_field, bd_table.TableFieldDestiny.AUTH_PHOTO_DOCS, bd_table.TableFieldType.PHOTO), + bd_table.TableField(user_photo_pay_field, bd_table.TableFieldDestiny.PHOTO_PAY, bd_table.TableFieldType.PHOTO), bd_table.TableField(access_field, bd_table.TableFieldDestiny.ACCESS, bd_table.TableFieldType.STR), bd_table.TableField(create_datetime_field, bd_table.TableFieldDestiny.CREATE_DATE, bd_table.TableFieldType.STR), ] @@ -49,13 +53,11 @@ table = bd_table.Table(table_name, [ ] ) -init_access = f'{user_access.user_access_group_new}=va' +init_access = f'{user_access.user_access_group_new}=vea' def_init_access = f'{user_access.user_access_group_new}=a' -g_group_auth_name = 'authorize_users' def GetAuthorizeItem(a_Bot, a_UserID): items = bd_item.GetBDItemsTemplate(a_Bot, table_name, user_id_field)(a_UserID) - print('GetAuthorizeItem', items) if len(items) == 1: return items[0] return None @@ -82,6 +84,9 @@ button_names = { mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_CONFIRM): "☐ Изменить подтверждение пользователя", mod_table_operate.EditButton(bd_table.TableFieldDestiny.USER_ID): "☐ Изменить id пользователя", mod_table_operate.EditButton(bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.AUTH_PHOTO_DOCS): "☐ Загрузить подписанные документы", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.PHOTO_PAY): "☐ Оплатить членский взнос", + mod_table_operate.EditButton(bd_table.TableFieldDestiny.ACCESS): "✋ Доступ к авторизации пользователя", mod_table_operate.ButtonNames.DEL: "❌ Удалить авторизацию пользователя", mod_table_operate.EnumButton(ConfirmStatus.YES): "Да, все данные верны", mod_table_operate.EnumButton(ConfirmStatus.NO): "Нет, данные не верны", @@ -214,6 +219,12 @@ messages = { Введите новое подтверждение пользователя: ''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.AUTH_PHOTO_DOCS): f''' +Загрузите подписанный документ: +''', + mod_table_operate.EditMessage(bd_table.TableFieldDestiny.PHOTO_PAY): f''' +Загрузите чек по оплате ЧВ: +''', mod_table_operate.EditMessage(bd_table.TableFieldDestiny.ACCESS): f''' Текущий доступ к проекту: #{access_field} @@ -222,7 +233,7 @@ messages = { Введите новую строку доступа: ''', - mod_table_operate.Messages.SUCCESS_EDIT: '''✅ Проект успешно отредактирован!''', + mod_table_operate.Messages.SUCCESS_EDIT: '''✅ Данные успешно отредактированы!''', mod_table_operate.Messages.SELECT_TO_DELETE: ''' Выберите пользователя, у которого вы хотите удалить авторизованные данные. ''', @@ -264,6 +275,8 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): bd_table.TableFieldDestiny.USER_CONTACTS: user_access.AccessMode.NONE, bd_table.TableFieldDestiny.USER_CONFIRM: user_access.AccessMode.NONE, bd_table.TableFieldDestiny.ACCESS: user_access.AccessMode.NONE, + bd_table.TableFieldDestiny.AUTH_PHOTO_DOCS: user_access.AccessMode.ADD, + bd_table.TableFieldDestiny.PHOTO_PAY: user_access.AccessMode.ADD, } return cur_dict.get(a_Field.m_Destiny, super().GetAccessForEditKeyboardButtons(a_Field)) @@ -281,6 +294,17 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): a_Item[key_name_id],\ a_Item[access_field_id] + async def OnChangeField(self, a_Field, a_ItemID, a_ItemData, a_EditUserID): + super().OnChangeField(a_Field, a_ItemID, a_ItemData, a_EditUserID) + user_id_field_name = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.USER_ID) + user_id = a_ItemData[user_id_field_name] + user_confirm_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.USER_CONFIRM) + auth_docs_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.AUTH_PHOTO_DOCS) + pay_field_id = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.PHOTO_PAY) + item = GetAuthorizeItem(self.m_Bot, user_id) + if item and item[user_confirm_field_id] != '' and item[auth_docs_field_id] != '' and item[pay_field_id] != '': + users_groups_agregator.AddUserInGroup(self.m_Bot, user_id, user_access.user_access_group_auth_users) + def GetStartButtons(self, a_Message, a_UserGroups): user_id = str(a_Message.from_user.id) item = GetAuthorizeItem(self.m_Bot, user_id) @@ -290,6 +314,8 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): if item and item[user_confirm_field_id] == self.GetMessage(mod_table_operate.EnumMessageForView(ConfirmStatus.YES)).GetDesc(): cur_buttons += [[ButtonNames.LIST_AUTH_DOCS, user_access.AccessMode.VIEW]] + cur_buttons += [[mod_table_operate.EditButton(bd_table.TableFieldDestiny.AUTH_PHOTO_DOCS), user_access.AccessMode.VIEW]] + cur_buttons += [[mod_table_operate.EditButton(bd_table.TableFieldDestiny.PHOTO_PAY), user_access.AccessMode.VIEW]] else: cur_buttons += [[mod_table_operate.ButtonNames.ADD, user_access.AccessMode.ADD]] @@ -308,7 +334,7 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): result = {} for f in files: result.update({f: cur_dict}) - print(cur_dict) + return result button_name = self.GetButton(ButtonNames.LIST_AUTH_DOCS) @@ -329,9 +355,9 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): def AddBDItemFunc(self, a_ItemData, a_UserID): a_ItemData[user_id_field] = a_UserID - #a_ItemData[address_field] = '' + a_ItemData[user_auth_docs_field] = '' + a_ItemData[user_photo_pay_field] = '' result = super().AddBDItemFunc(a_ItemData, a_UserID) - users_groups_agregator.AddUserInGroup(self.m_Bot, a_UserID, g_group_auth_name) return result def GetKeyFieldDestiny(self): @@ -339,7 +365,7 @@ class ModuleAuthorize(mod_table_operate.TableOperateModule): def GetInitBDCommands(self): return super(). GetInitBDCommands() + [ - groups_utils.CreateGroupRequest(g_group_auth_name) + groups_utils.CreateGroupRequest(user_access.user_access_group_auth_users) ] def GetReplaceDictFunc(a_Bot, a_user_id): diff --git a/bot_modules/orders.py b/bot_modules/orders.py index edf6fd0..1c4a973 100644 --- a/bot_modules/orders.py +++ b/bot_modules/orders.py @@ -45,7 +45,7 @@ table = bd_table.Table(table_name, [ bd_table.TableField(parent_id_field, bd_table.TableFieldDestiny.PARENT_ID, bd_table.TableFieldType.INT), ]) -init_access = f'{user_access.user_access_group_new}=vea' +init_access = f'{user_access.user_access_group_auth_users}=vea' # --------------------------------------------------------- # Сообщения и кнопки diff --git a/bot_sys/bd_table.py b/bot_sys/bd_table.py index 2af2e98..25c2981 100644 --- a/bot_sys/bd_table.py +++ b/bot_sys/bd_table.py @@ -46,6 +46,7 @@ class TableFieldDestiny(Enum): USER_ADDRESS = auto() # Адресс USER_CONTACTS = auto() # контакты USER_CONFIRM = auto() # подтверждение + AUTH_PHOTO_DOCS = auto() class TableField: def __init__(self, a_Name, a_Destiny : TableFieldDestiny, a_Type : TableFieldType, a_Enum = None): diff --git a/bot_sys/user_access.py b/bot_sys/user_access.py index 29750ca..39394cd 100644 --- a/bot_sys/user_access.py +++ b/bot_sys/user_access.py @@ -8,6 +8,7 @@ from bot_sys import config user_access_group_all = 'all' user_access_group_new = 'new' +user_access_group_auth_users = 'authorize_users' user_access_readme = f''' Доступ к пользователям задаётся в виде строки @@ -57,6 +58,7 @@ def CheckAccessItem(a_AccessItem : str, a_AccessMode : AccessMode): # Возвращает возможность доступа пользователю a_UserGroups в элемент с правами a_AccessValue по режиму доступа a_AccessMode def CheckAccess(a_RootIDs, a_AccessValue : str, a_UserGroups : UserGroups, a_AccessMode : AccessMode): + #print(a_RootIDs, a_AccessValue, a_UserGroups, a_AccessMode) if a_UserGroups.user_id in a_RootIDs: return True for i in a_AccessValue.split(';'):