upd get_callable_str async
This commit is contained in:
@@ -100,13 +100,13 @@ async def entity_item(
|
||||
]
|
||||
field_value = getattr(entity_item, field_descriptor.field_name)
|
||||
if btn_caption:
|
||||
btn_text = get_callable_str(
|
||||
btn_text = await get_callable_str(
|
||||
btn_caption, field_descriptor, entity_item, field_value
|
||||
)
|
||||
else:
|
||||
if field_descriptor.type_base is bool:
|
||||
btn_text = f"{'【✔︎】 ' if field_value else '【 】 '}{
|
||||
get_callable_str(
|
||||
await get_callable_str(
|
||||
field_descriptor.caption,
|
||||
field_descriptor,
|
||||
entity_item,
|
||||
@@ -116,18 +116,20 @@ async def entity_item(
|
||||
else field_name
|
||||
}"
|
||||
else:
|
||||
btn_text = (
|
||||
f"✏️ {
|
||||
get_callable_str(
|
||||
field_descriptor.caption,
|
||||
field_descriptor,
|
||||
entity_item,
|
||||
field_value,
|
||||
)
|
||||
}"
|
||||
btn_text = f"{
|
||||
field_descriptor.icon
|
||||
if field_descriptor.icon
|
||||
else '✏️'
|
||||
} {
|
||||
await get_callable_str(
|
||||
field_descriptor.caption,
|
||||
field_descriptor,
|
||||
entity_item,
|
||||
field_value,
|
||||
)
|
||||
if field_descriptor.caption
|
||||
else f"✏️ {field_name}"
|
||||
)
|
||||
else field_name
|
||||
}"
|
||||
btn_row.append(
|
||||
InlineKeyboardButton(
|
||||
text=btn_text,
|
||||
@@ -144,7 +146,7 @@ async def entity_item(
|
||||
elif isinstance(button, CommandButton):
|
||||
btn_caption = button.caption
|
||||
|
||||
btn_text = get_callable_str(
|
||||
btn_text = await get_callable_str(
|
||||
btn_caption, entity_descriptor, entity_item
|
||||
)
|
||||
|
||||
@@ -215,7 +217,7 @@ async def entity_item(
|
||||
item_text = form.item_repr(entity_descriptor, entity_item)
|
||||
else:
|
||||
entity_caption = (
|
||||
get_callable_str(
|
||||
await get_callable_str(
|
||||
entity_descriptor.full_name, entity_descriptor, entity_item
|
||||
)
|
||||
if entity_descriptor.full_name
|
||||
@@ -223,7 +225,7 @@ async def entity_item(
|
||||
)
|
||||
|
||||
entity_item_repr = (
|
||||
get_callable_str(
|
||||
await get_callable_str(
|
||||
entity_descriptor.item_repr, entity_descriptor, entity_item
|
||||
)
|
||||
if entity_descriptor.item_repr
|
||||
@@ -234,18 +236,18 @@ async def entity_item(
|
||||
|
||||
for field_descriptor in entity_descriptor.fields_descriptors.values():
|
||||
if field_descriptor.is_visible:
|
||||
field_caption = get_callable_str(
|
||||
field_caption = await get_callable_str(
|
||||
field_descriptor.caption, field_descriptor, entity_item
|
||||
)
|
||||
if field_descriptor.caption_value:
|
||||
value = get_callable_str(
|
||||
value = await get_callable_str(
|
||||
field_descriptor.caption_value,
|
||||
field_descriptor,
|
||||
entity_item,
|
||||
getattr(entity_item, field_descriptor.field_name),
|
||||
)
|
||||
else:
|
||||
value = get_value_repr(
|
||||
value = await get_value_repr(
|
||||
value=getattr(entity_item, field_descriptor.field_name),
|
||||
field_descriptor=field_descriptor,
|
||||
locale=user.lang,
|
||||
|
||||
@@ -61,7 +61,7 @@ async def entity_delete_callback(query: CallbackQuery, **kwargs):
|
||||
return await query.message.edit_text(
|
||||
text=(
|
||||
await Settings.get(Settings.APP_STRINGS_CONFIRM_DELETE_P_NAME)
|
||||
).format(name=get_entity_item_repr(entity=entity)),
|
||||
).format(name=await get_entity_item_repr(entity=entity)),
|
||||
reply_markup=InlineKeyboardBuilder()
|
||||
.row(
|
||||
InlineKeyboardButton(
|
||||
|
||||
@@ -197,7 +197,7 @@ async def entity_list(
|
||||
caption = entity_descriptor.item_repr(entity_descriptor, item)
|
||||
elif entity_descriptor.full_name:
|
||||
caption = f"{
|
||||
get_callable_str(
|
||||
await get_callable_str(
|
||||
callable_str=entity_descriptor.full_name,
|
||||
descriptor=entity_descriptor,
|
||||
entity=item,
|
||||
@@ -228,7 +228,7 @@ async def entity_list(
|
||||
)
|
||||
|
||||
if form_list.filtering and form_list.filtering_fields:
|
||||
add_filter_controls(
|
||||
await add_filter_controls(
|
||||
keyboard_builder=keyboard_builder,
|
||||
entity_descriptor=entity_descriptor,
|
||||
filter=entity_filter,
|
||||
@@ -245,17 +245,17 @@ async def entity_list(
|
||||
)
|
||||
|
||||
if form_list.caption:
|
||||
entity_text = get_callable_str(form_list.caption, entity_descriptor)
|
||||
entity_text = await get_callable_str(form_list.caption, entity_descriptor)
|
||||
else:
|
||||
if entity_descriptor.full_name_plural:
|
||||
entity_text = get_callable_str(
|
||||
entity_text = await get_callable_str(
|
||||
entity_descriptor.full_name_plural, entity_descriptor
|
||||
)
|
||||
else:
|
||||
entity_text = entity_descriptor.name
|
||||
|
||||
if entity_descriptor.description:
|
||||
entity_text = f"{entity_text} {get_callable_str(entity_descriptor.description, entity_descriptor)}"
|
||||
entity_text = f"{entity_text} {await get_callable_str(entity_descriptor.description, entity_descriptor)}"
|
||||
|
||||
state: FSMContext = kwargs["state"]
|
||||
state_data = kwargs["state_data"]
|
||||
|
||||
Reference in New Issue
Block a user