Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
c96258e1
Unverified
Commit
c96258e1
authored
Mar 07, 2019
by
Jürgen Gmach
Committed by
GitHub
Mar 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify example code
As has_role returns a boolean anyway, there is no need for another if-statement.
parent
0c4d2c9f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
6 deletions
+1
-6
app.py
examples/auth/app.py
+1
-6
No files found.
examples/auth/app.py
View file @
c96258e1
...
@@ -54,15 +54,10 @@ security = Security(app, user_datastore)
...
@@ -54,15 +54,10 @@ security = Security(app, user_datastore)
# Create customized model view class
# Create customized model view class
class
MyModelView
(
sqla
.
ModelView
):
class
MyModelView
(
sqla
.
ModelView
):
def
is_accessible
(
self
):
def
is_accessible
(
self
):
if
not
current_user
.
is_active
or
not
current_user
.
is_authenticated
:
if
not
current_user
.
is_active
or
not
current_user
.
is_authenticated
:
return
False
return
False
return
current_user
.
has_role
(
'superuser'
)
if
current_user
.
has_role
(
'superuser'
):
return
True
return
False
def
_handle_view
(
self
,
name
,
**
kwargs
):
def
_handle_view
(
self
,
name
,
**
kwargs
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment