Commit 5d546b1d authored by Jürgen Gmach's avatar Jürgen Gmach

Refactor is_accessible

Now, no more if statements are used.

Also, this should be more readable, and even faster, as in case of any
False value, the method can return early.

modified:   examples/auth/app.py
parent c96258e1
......@@ -55,9 +55,10 @@ security = Security(app, user_datastore)
# Create customized model view class
class MyModelView(sqla.ModelView):
def is_accessible(self):
if not current_user.is_active or not current_user.is_authenticated:
return False
return current_user.has_role('superuser')
return (current_user.is_active and
current_user.is_authenticated and
current_user.has_role('superuser')
)
def _handle_view(self, name, **kwargs):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment