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
3336689a
Commit
3336689a
authored
Nov 01, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #111 from Koblaid/AdminIndexView_add_template_parameter
Added parameter 'template' to AdminIndexView.__init__()
parents
08bb9cab
e01deb7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
base.py
flask_admin/base.py
+8
-3
test_base.py
flask_admin/tests/test_base.py
+19
-0
No files found.
flask_admin/base.py
View file @
3336689a
...
@@ -264,7 +264,8 @@ class AdminIndexView(BaseView):
...
@@ -264,7 +264,8 @@ class AdminIndexView(BaseView):
class MyHomeView(AdminIndexView):
class MyHomeView(AdminIndexView):
@expose('/')
@expose('/')
def index(self):
def index(self):
return render_template('adminhome.html')
arg1 = 'Hello'
return render_template('adminhome.html', arg1=arg1)
admin = Admin(index_view=MyHomeView())
admin = Admin(index_view=MyHomeView())
...
@@ -274,17 +275,21 @@ class AdminIndexView(BaseView):
...
@@ -274,17 +275,21 @@ class AdminIndexView(BaseView):
* If endpoint is not provided, will use ``admin``
* If endpoint is not provided, will use ``admin``
* Default URL route is ``/admin``.
* Default URL route is ``/admin``.
* Automatically associates with static folder.
* Automatically associates with static folder.
* Default template is ``admin/index.html``
"""
"""
def
__init__
(
self
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
):
def
__init__
(
self
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
,
template
=
'admin/index.html'
):
super
(
AdminIndexView
,
self
)
.
__init__
(
name
or
babel
.
lazy_gettext
(
'Home'
),
super
(
AdminIndexView
,
self
)
.
__init__
(
name
or
babel
.
lazy_gettext
(
'Home'
),
category
,
category
,
endpoint
or
'admin'
,
endpoint
or
'admin'
,
url
or
'/admin'
,
url
or
'/admin'
,
'static'
)
'static'
)
self
.
_template
=
template
@
expose
()
@
expose
()
def
index
(
self
):
def
index
(
self
):
return
self
.
render
(
'admin/index.html'
)
return
self
.
render
(
self
.
_template
)
class
MenuItem
(
object
):
class
MenuItem
(
object
):
...
...
flask_admin/tests/test_base.py
View file @
3336689a
...
@@ -45,14 +45,33 @@ def test_base_defaults():
...
@@ -45,14 +45,33 @@ def test_base_defaults():
admin
=
base
.
Admin
()
admin
=
base
.
Admin
()
eq_
(
admin
.
name
,
'Admin'
)
eq_
(
admin
.
name
,
'Admin'
)
eq_
(
admin
.
url
,
'/admin'
)
eq_
(
admin
.
url
,
'/admin'
)
eq_
(
admin
.
endpoint
,
'admin'
)
eq_
(
admin
.
app
,
None
)
eq_
(
admin
.
app
,
None
)
ok_
(
admin
.
index_view
is
not
None
)
ok_
(
admin
.
index_view
is
not
None
)
eq_
(
admin
.
index_view
.
_template
,
'admin/index.html'
)
# Check if default view was added
# Check if default view was added
eq_
(
len
(
admin
.
_views
),
1
)
eq_
(
len
(
admin
.
_views
),
1
)
eq_
(
admin
.
_views
[
0
],
admin
.
index_view
)
eq_
(
admin
.
_views
[
0
],
admin
.
index_view
)
def
test_custom_index_view
():
view
=
base
.
AdminIndexView
(
name
=
'a'
,
category
=
'b'
,
endpoint
=
'c'
,
url
=
'/d'
,
template
=
'e'
)
admin
=
base
.
Admin
(
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
():
def
test_base_registration
():
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
admin
=
base
.
Admin
(
app
)
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