I'm using Flask-Admin to manage my dashboard, there are few roles in my app, two of them are superuser and client .
Now, I have User table build by Flask-SQLAlchemy , and now I want to manage the table by users role. Which means the superuser can edit user roles in the Flask-Admin form, and in the other client can't do it or the form are not displayed.
Like this screenshot: there are edit form by superuser role. But for now, I want the edit form not displayed if the current user has role client .
So, in logically I want to making something like this:
class UserModelView(sqla.ModelView):
if current_user.has_role('superuser'):
form_excluded_columns = ('created_at', 'updated_at')
else:
form_excluded_columns = ('created_at', 'updated_at', 'roles')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.