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
56908b59
Commit
56908b59
authored
Aug 27, 2015
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #619 - Provide overridable method to change URL generation logic
parent
cb8967d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
base.py
flask_admin/base.py
+20
-12
No files found.
flask_admin/base.py
View file @
56908b59
...
...
@@ -216,6 +216,24 @@ class BaseView(with_metaclass(AdminViewMeta, BaseViewClass)):
return
self
.
__class__
.
__name__
.
lower
()
def
_get_view_url
(
self
,
admin
,
url
):
"""
Generate URL for the view. Override to change default behavior.
"""
if
url
is
None
:
if
admin
.
url
!=
'/'
:
url
=
'
%
s/
%
s'
%
(
admin
.
url
,
self
.
endpoint
)
else
:
if
self
==
admin
.
index_view
:
url
=
'/'
else
:
url
=
'/
%
s'
%
self
.
endpoint
else
:
if
not
url
.
startswith
(
'/'
):
url
=
'
%
s/
%
s'
%
(
admin
.
url
,
url
)
return
url
def
create_blueprint
(
self
,
admin
):
"""
Create Flask blueprint.
...
...
@@ -227,18 +245,8 @@ class BaseView(with_metaclass(AdminViewMeta, BaseViewClass)):
if
not
self
.
static_url_path
:
self
.
static_url_path
=
admin
.
static_url_path
# If url is not provided, generate it from endpoint name
if
self
.
url
is
None
:
if
self
.
admin
.
url
!=
'/'
:
self
.
url
=
'
%
s/
%
s'
%
(
self
.
admin
.
url
,
self
.
endpoint
)
else
:
if
self
==
admin
.
index_view
:
self
.
url
=
'/'
else
:
self
.
url
=
'/
%
s'
%
self
.
endpoint
else
:
if
not
self
.
url
.
startswith
(
'/'
):
self
.
url
=
'
%
s/
%
s'
%
(
self
.
admin
.
url
,
self
.
url
)
# Generate URL
self
.
url
=
self
.
_get_view_url
(
admin
,
self
.
url
)
# If we're working from the root of the site, set prefix to None
if
self
.
url
==
'/'
:
...
...
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