@ -214,23 +214,47 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
a_Msg . UpdatePhotoID ( ' , ' . join ( photos ) )
return a_Msg
def GetParentID ( self , a_Item , a_ItemDict , a_TableName ) :
parent_id = None
parent_id_field = self . m_Table . GetFieldNameByDestiny ( bd_table . TableFieldDestiny . PARENT_ID )
if parent_id_field and a_ItemDict and parent_id_field in a_ItemDict :
parent_id = str ( a_ItemDict [ parent_id_field ] )
parent_id_field_id = self . m_Table . GetFieldIDByDestiny ( bd_table . TableFieldDestiny . PARENT_ID )
if not parent_id and parent_id_field_id != None and a_Item and len ( a_Item ) == self . m_Table . GetFieldsCount ( ) and self . m_Table . GetName ( ) == a_TableName :
parent_id = str ( a_Item [ parent_id_field_id ] )
if self . m_ParentModName :
parent_mod = self . GetModule ( self . m_ParentModName )
if parent_mod :
key_field_id = parent_mod . m_Table . GetFieldIDByDestiny ( bd_table . TableFieldDestiny . KEY )
if not parent_id and key_field_id != None and a_Item and len ( a_Item ) == parent_mod . m_Table . GetFieldsCount ( ) and parent_mod . m_Table . GetName ( ) == a_TableName :
parent_id = str ( a_Item [ key_field_id ] )
return parent_id
def ShowMessageTemplate ( self , a_Message , Inline_keyboard_template_func = None , a_EnablePhoto = False ) :
async def ShowMessage ( a_CallbackQuery , a_Item , a_ItemDict , table_name = self . m_Table . GetName ( ) ) :
lang = str ( a_CallbackQuery . from_user . language_code )
msg = a_Message . StaticCopy ( )
# Подменяем сообщение, если оно уже есть для PARENT_ID
parent_id = self . GetParentID ( a_Item , a_ItemDict , table_name )
if parent_id :
name = msg . GetName ( ) + ' ? ' + str ( bd_table . TableFieldDestiny . PARENT_ID ) + ' = ' + parent_id
parent_id_msg = a_Message . FindMessageForLang ( name , lang )
if parent_id_msg :
msg = parent_id_msg
msg = msg . GetMessageForLang ( lang ) . 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 and self . m_Table . GetName ( ) == table_name :
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 ) )
elif len ( a_Item ) == self . m_Table . GetFieldsCount ( ) :
lang = str ( a_CallbackQuery . from_user . language_code )
msg = msg . GetMessageForLang ( lang ) . StaticCopy ( )
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 :
@ -247,7 +271,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
async def PostDelete ( self , a_CallbackQuery , a_ItemID ) :
user_id = a_CallbackQuery . from_user . id
self . m_Log . Success ( f ' Задача №{ a_ItemID } была удалена пользователем { user_id } . ' )
self . m_Log . Success ( f ' Элемент №{ a_ItemID } была удалена пользователем { user_id } . ' )
#TODO: удалить вложенные
self . OnChange ( )