|
|
|
@ -18,18 +18,14 @@ def GetBDItemsListKeyboardButtonsTemplate(a_TableName : str, a_ParentIDFieldName
|
|
|
|
|
else: |
|
|
|
|
items = bd_item.GetAllItemsTemplate(a_TableName)() |
|
|
|
|
|
|
|
|
|
print('GetBDItemsListKeyboardButtons', parent_id, a_PrevPrefix, a_ParentIDFieldName, "\n", items) |
|
|
|
|
items_button_list = [] |
|
|
|
|
for t in items: |
|
|
|
|
print('GetBDItemsListKeyboardButtons items', t) |
|
|
|
|
bname, key_value, access = a_GetButtonNameAndKeyValueAndAccessFunc(t) |
|
|
|
|
if access is None: |
|
|
|
|
access = '' |
|
|
|
|
if not bname is None and user_access.CheckAccessString(access, a_UserGroups, access_mode): |
|
|
|
|
b = keyboard.Button(bname, key_value) |
|
|
|
|
print(bname, key_value, b) |
|
|
|
|
items_button_list += [b] |
|
|
|
|
print(items_button_list) |
|
|
|
|
return keyboard.MakeInlineKeyboard(items_button_list, a_NextPrefix) |
|
|
|
|
return GetBDItemsListKeyboardButtons |
|
|
|
|
|
|
|
|
@ -37,15 +33,9 @@ def SelectDBItemTemplate(a_TableName : str, a_ParentIDFieldName, a_GetButtonName
|
|
|
|
|
keyboard_func = GetBDItemsListKeyboardButtonsTemplate(a_TableName, a_ParentIDFieldName, a_PrevPrefix, a_NextPrefix, a_GetButtonNameAndKeyValueAndAccessFunc) |
|
|
|
|
return simple_message.InfoMessageTemplate(a_StartMessage, keyboard_func, a_AccessFunc, access_mode) |
|
|
|
|
|
|
|
|
|
def hash_str(a_Str): |
|
|
|
|
summ = 0 |
|
|
|
|
for i in a_Str: |
|
|
|
|
summ += ord(i) |
|
|
|
|
return f'{summ}:' |
|
|
|
|
|
|
|
|
|
def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): |
|
|
|
|
|
|
|
|
|
a_Prefix = hash_str(f'first_select_{a_TableName}_{a_KeyName}_in_base_{a_PrefixBase}:') |
|
|
|
|
a_Prefix = bd_item.HashPrefix(f'first_select_{a_TableName}_{a_KeyName}_in_base_{a_PrefixBase}:') |
|
|
|
|
|
|
|
|
|
sel_handler = SelectDBItemTemplate(a_TableName, None, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, None, a_Prefix, access_mode = access_mode) |
|
|
|
|
dp.register_message_handler(sel_handler, text = a_ButtonName) |
|
|
|
@ -53,7 +43,7 @@ def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableNam
|
|
|
|
|
return a_Prefix, sel_handler |
|
|
|
|
|
|
|
|
|
def NextSelectBDItemRegisterHandlers(dp, a_PrevPrefix, a_ParentIDFieldName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): |
|
|
|
|
a_Prefix = f'next_select_{a_TableName}_{a_KeyName}_{a_ParentIDFieldName}_after_prefix_{a_PrevPrefix}:' |
|
|
|
|
a_Prefix = bd_item.HashPrefix(f'next_select_{a_TableName}_{a_KeyName}_{a_ParentIDFieldName}_after_prefix_{a_PrevPrefix}:') |
|
|
|
|
|
|
|
|
|
sel_handler = SelectDBItemTemplate(a_TableName, a_ParentIDFieldName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_PrevPrefix, a_Prefix, access_mode = access_mode) |
|
|
|
|
dp.register_callback_query_handler(sel_handler, bd_item.GetCheckForPrefixFunc(a_PrevPrefix)) |
|
|
|
|