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,
|
||||
|
||||
Reference in New Issue
Block a user