is there a good way to hide / prevent access to Docked windows based on security level / Role / of logged in user?
I have some admin windows that are docked with handle to expose them, but I only want those to be there if Role = "admin"
is there a good way to hide / prevent access to Docked windows based on security level / Role / of logged in user?
I have some admin windows that are docked with handle to expose them, but I only want those to be there if Role = "admin"
I would do the following:
if "admin" in self.session.props.auth.user.roles:
return True
return False
There is no way to configure the presence of Docked Views via Security Levels or Roles, but you can absolutely place those security restrictions on the View itself so that the View doesn't render unless the User has the required permissions.
I suppose one approximation of this behavior would be to have all Docked Views collapsed by default, and each Docked View would have a custom property bound to an expression which makes the check against permissions. in a change script for the property, you could then invoke system.perspective.openDock(...)
.
Custom UI to expand/collapse Docked Views is great and allows for the best custom handling, but it also means you need to position that UI across all Views which would be used as Primary Views.
Could be cleaned up:
# Anytime you find yourself with an if/else -> True/False
# bit of logic, ask yourself if there's a cleaner way to implement.
return "admin" in self.session.props.auth.user.roles