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
1766909e
Commit
1766909e
authored
Mar 24, 2016
by
michael lynch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding tests to see why the PR failed.
parent
7d36dde6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
17 deletions
+41
-17
base.py
flask_admin/base.py
+22
-17
test_base.py
flask_admin/tests/test_base.py
+19
-0
No files found.
flask_admin/base.py
View file @
1766909e
...
...
@@ -518,7 +518,7 @@ class Admin(object):
self
.
template_mode
=
template_mode
or
'bootstrap2'
self
.
category_icon_classes
=
category_icon_classes
or
dict
()
# Add
predefined
index view
# Add index view
self
.
_set_admin_index_view
(
index_view
=
index_view
,
endpoint
=
endpoint
,
url
=
url
)
# Register with application
...
...
@@ -559,6 +559,10 @@ class Admin(object):
self
.
url
=
url
or
self
.
index_view
.
url
# Add predefined index view
# assume index view is always the first element of views.
if
len
(
self
.
_views
)
>
0
:
self
.
_views
[
0
]
=
self
.
index_view
else
:
self
.
add_view
(
self
.
index_view
)
def
add_views
(
self
,
*
args
):
...
...
@@ -659,12 +663,13 @@ class Admin(object):
self
.
_init_extension
()
# Register Index view
self
.
_set_admin_index_view
(
index_view
=
index_view
,
endpoint
=
endpoint
,
url
=
url
)
# Register views
for
view
in
self
.
_views
:
app
.
register_blueprint
(
view
.
create_blueprint
(
self
))
# Register Index view
self
.
_set_admin_index_view
(
index_view
=
index_view
,
endpoint
=
endpoint
,
url
=
url
)
def
_init_extension
(
self
):
if
not
hasattr
(
self
.
app
,
'extensions'
):
...
...
flask_admin/tests/test_base.py
View file @
1766909e
...
...
@@ -114,6 +114,25 @@ def test_custom_index_view():
eq_
(
admin
.
_views
[
0
],
view
)
def
test_custom_index_view_in_init_app
():
view
=
base
.
AdminIndexView
(
name
=
'a'
,
category
=
'b'
,
endpoint
=
'c'
,
url
=
'/d'
,
template
=
'e'
)
app
=
Flask
(
__name__
)
admin
=
base
.
Admin
()
admin
.
init_app
(
app
,
index_view
=
view
)
eq_
(
admin
.
endpoint
,
'c'
)
eq_
(
admin
.
url
,
'/d'
)
ok_
(
admin
.
index_view
is
view
)
eq_
(
view
.
name
,
'a'
)
eq_
(
view
.
category
,
'b'
)
eq_
(
view
.
_template
,
'e'
)
# Check if view was added
eq_
(
len
(
admin
.
_views
),
1
)
eq_
(
admin
.
_views
[
0
],
view
)
def
test_base_registration
():
app
=
Flask
(
__name__
)
admin
=
base
.
Admin
(
app
)
...
...
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