Browse Source

Протестирована авторизация нового пользователя до момента документов

auth_koop
Alexei 1 year ago
parent
commit
d7ea8ecd75
  1. 51
      auth_docs/test_doc.odt
  2. 38
      bot_modules/authorize.py
  3. 48
      bot_modules/mod_table_operate.py
  4. 7
      bot_modules/subscribes.py
  5. 7
      bot_sys/bd_table.py
  6. 2
      template/bd_item.py
  7. 4
      template/bd_item_add.py

51
auth_docs/test_doc.odt

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
<office:meta><dc:date>2023-10-08T23:17:27.894126099</dc:date><meta:editing-duration>PT46S</meta:editing-duration><meta:editing-cycles>2</meta:editing-cycles><meta:generator>LibreOffice/7.3.6.2$Linux_X86_64 LibreOffice_project/30$Build-2</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="8" meta:word-count="16" meta:character-count="637" meta:non-whitespace-character-count="545"/></office:meta>
<office:meta><dc:date>2023-10-13T15:56:51.616305329</dc:date><meta:editing-duration>PT1M19S</meta:editing-duration><meta:editing-cycles>4</meta:editing-cycles><meta:generator>LibreOffice/7.3.6.2$Linux_X86_64 LibreOffice_project/30$Build-2</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="8" meta:word-count="16" meta:character-count="638" meta:non-whitespace-character-count="545"/></office:meta>
<office:settings>
<config:config-item-set config:name="ooo:view-settings">
<config:config-item config:name="ViewAreaTop" config:type="long">0</config:config-item>
@ -13,8 +13,8 @@
<config:config-item-map-indexed config:name="Views">
<config:config-item-map-entry>
<config:config-item config:name="ViewId" config:type="string">view2</config:config-item>
<config:config-item config:name="ViewLeft" config:type="long">22826</config:config-item>
<config:config-item config:name="ViewTop" config:type="long">5909</config:config-item>
<config:config-item config:name="ViewLeft" config:type="long">18221</config:config-item>
<config:config-item config:name="ViewTop" config:type="long">3475</config:config-item>
<config:config-item config:name="VisibleLeft" config:type="long">0</config:config-item>
<config:config-item config:name="VisibleTop" config:type="long">0</config:config-item>
<config:config-item config:name="VisibleRight" config:type="long">35586</config:config-item>
@ -88,7 +88,7 @@
<config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrinterSetup" config:type="base64Binary"/>
<config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item>
<config:config-item config:name="Rsid" config:type="int">820887</config:config-item>
<config:config-item config:name="Rsid" config:type="int">918403</config:config-item>
<config:config-item config:name="EmbeddedDatabaseName" config:type="string"/>
<config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item>
<config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item>
@ -149,7 +149,7 @@
<office:styles>
<style:default-style style:family="graphic">
<style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:font-independent-line-spacing="false">
<style:tab-stops/>
</style:paragraph-properties>
<style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="ru" fo:country="RU" style:letter-kerning="true" style:font-name-asian="Droid Sans Fallback" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Droid Sans Devanagari1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/>
@ -184,52 +184,52 @@
<style:text-properties fo:language="zxx" fo:country="none" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Droid Sans Devanagari" style:font-family-complex="&apos;Droid Sans Devanagari&apos;" style:font-family-generic-complex="swiss" style:language-complex="zxx" style:country-complex="none"/>
</style:style>
<text:outline-style style:name="Outline">
<text:outline-level-style text:level="1" style:num-format="">
<text:outline-level-style text:level="1" loext:num-list-format="%1%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="2" style:num-format="">
<text:outline-level-style text:level="2" loext:num-list-format="%2%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="3" style:num-format="">
<text:outline-level-style text:level="3" loext:num-list-format="%3%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="4" style:num-format="">
<text:outline-level-style text:level="4" loext:num-list-format="%4%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="5" style:num-format="">
<text:outline-level-style text:level="5" loext:num-list-format="%5%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="6" style:num-format="">
<text:outline-level-style text:level="6" loext:num-list-format="%6%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="7" style:num-format="">
<text:outline-level-style text:level="7" loext:num-list-format="%7%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="8" style:num-format="">
<text:outline-level-style text:level="8" loext:num-list-format="%8%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="9" style:num-format="">
<text:outline-level-style text:level="9" loext:num-list-format="%9%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
</text:outline-level-style>
<text:outline-level-style text:level="10" style:num-format="">
<text:outline-level-style text:level="10" loext:num-list-format="%10%" style:num-format="">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab"/>
</style:list-level-properties>
@ -240,16 +240,22 @@
<text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
</office:styles>
<office:automatic-styles>
<style:style style:name="T1" style:family="text">
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
</style:style>
<style:page-layout style:name="pm1">
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm" loext:margin-gutter="0cm">
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm">
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
</style:page-layout-properties>
<style:header-style/>
<style:footer-style/>
</style:page-layout>
<style:style style:name="dp1" style:family="drawing-page">
<style:drawing-page-properties draw:background-size="full"/>
</style:style>
</office:automatic-styles>
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="pm1"/>
<style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/>
</office:master-styles>
<office:body>
<office:text>
@ -260,13 +266,22 @@
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
<text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
</text:sequence-decls>
<text:p text:style-name="Standard">bd_table.TableFieldDestiny.USER_NAME: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:tab/><text:span text:style-name="T1">bd_table.TableFieldDestiny.USER_NAME</text:span>: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.USER_FAMILY_NAME: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.USER_MIDDLE_NAME: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.USER_BIRTHDAY: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.USER_ADDRESS: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.USER_CONTACTS: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.USER_CONFIRM: user_access.AccessMode.NONE,</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:s text:c="12"/>bd_table.TableFieldDestiny.ACCESS: user_access.AccessMode.NONE,</text:p>
</office:text>
</office:body>

38
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:

48
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

7
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)

7
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()

2
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

4
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()

Loading…
Cancel
Save