I want to making a condional on Flask-Admin methods feature.
But confusing about how to give a conditional between users roles, let says in the can_create feature.
Here is the snippet of my modelview:
class UserModelView(sqla.ModelView):
if current_user.has_role == 'superuser':
can_create = True
elif current_user.has_role == 'client':
can_create = False
But I'm getting few errors, and I have also tried the different ways, like this:
class UserModelView(sqla.ModelView):
def is_visible(self):
if current_user.has_role == 'superuser':
can_create = True
elif current_user.has_role == 'client':
can_create = False
and I have also tried it with other methods on BaseModelView
class, but still don't work like I want.
So.. is it possible to give conditional in that feature..?