Enums no appropriate shows in admin
Thanks for your product. It helps much.
Scope
In admin-panel some list resources that have enum property
Prerequisites
class AuthConfirmType(enum.Enum):
SMS = "СМС"
BIRTH_DAY = "Дата рождения"
settings = sa.Table(
"settings",
meta,
sa.Column("id", sa.Integer(), primary_key=True),
.....
sa.Column(
"auth_confirm_by",
sa.Enum(AuthConfirmType),
nullable=True,
)
)
Description
In admin-panel I catch error on detail-action.
if I change enums on this (add str )
class AuthConfirmType(str, enum.Enum):
SMS = "СМС"
BIRTH_DAY = "Дата рождения"
I will catch misleading value, that no will use properly.
To hook this misbehavior need override jsonEncoder, but in PGResource I can't use mixins, ( only copy-paste,
It's pain
Thx for your feedback.
If i understand correct you have problem with json_response function from utils. Quick solution without copy-paste is monkey patch.
import aiohttp_admon
aiohttp_admin.utils.json_response = my_patch_function
Yes, monkey patch it's not good but much easier in your case.
We can write json_response method inside PGResource class for give ease approach to rewrite this function.
if u need this feature now and don't want to wait u can make MR with changes 😀