You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I figured out why.
The problem is that the callable expects an extra argument namely handler.
The check_permission function in admin_extra_buttons.utils is called and your permission callable is passed to this function. However the check_permissionfunction calls the callable not only with the request and object as arguments, but also with handler as an argument. This raises an error, but this is somehow caught somewhere and not raised so we don't know it is actually failing.
def check_permission(handler, permission, request, obj=None):
if callable(permission):
if not permission(request, obj, handler=handler):
raise PermissionDenied
elif not request.user.has_perm(permission):
raise PermissionDenied
return True
If you add the handler to the kwargs of your callable it will work as intended @button(permission=lambda request, obj, handler: True)
I'm not sure why the check_permission function passes the handler to the callable. It should either be removed or the documentation should be updated accordingly
I've tried
permission
property and it seems it hides the button no matter what value is provided from the permission function.a simple button
the button is hidden.
the button is still hidden (why?)
The text was updated successfully, but these errors were encountered: