Hi i want to check which role a user has. A admin user should see all entries of an object. If the user is not an admin the user should see only its own entries. I got the stuff ready for the user who only can see its data. But i have a problem with the role of the user. When i call the function get_user_role() i get the error Working outside of application context. When i leave the brakets away it is not called. I can not use the base_filtering because i have not attribute role in the model. Maybe i have a understanding problem with the whole context thing. Does anyone has a clue how i could achieve the my goal. thanks in advance
def get_user():
return g.user.id
def get_user_role():
return g.user.roles
class MeasuringDevicePosView(ModelView):
datamodel = SQLAInterface(MeasuringDevicePos)
if(get_user_role != 'Admin'):
base_filters = [['user_id', FilterEqualFunction, get_user]]