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
3d957d9f
Commit
3d957d9f
authored
Mar 15, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #168. Allow base template overriding
parent
bc6d7555
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
93 deletions
+99
-93
base.py
flask_admin/base.py
+8
-3
base.html
flask_admin/templates/admin/base.html
+90
-0
master.html
flask_admin/templates/admin/master.html
+1
-90
No files found.
flask_admin/base.py
View file @
3d957d9f
...
...
@@ -174,7 +174,7 @@ class BaseView(object):
# If endpoint name is not provided, get it from the class name
if
self
.
endpoint
is
None
:
self
.
endpoint
=
self
.
__class__
.
__name__
.
lower
()
# If the static_url_path is not provided, use the admin's
if
not
self
.
static_url_path
:
self
.
static_url_path
=
admin
.
static_url_path
...
...
@@ -227,6 +227,7 @@ class BaseView(object):
"""
# Store self as admin_view
kwargs
[
'admin_view'
]
=
self
kwargs
[
'admin_base_template'
]
=
self
.
admin
.
base_template
# Provide i18n support even if flask-babel is not installed
# or enabled.
...
...
@@ -385,7 +386,8 @@ class Admin(object):
index_view
=
None
,
translations_path
=
None
,
endpoint
=
None
,
static_url_path
=
None
):
static_url_path
=
None
,
base_template
=
None
):
"""
Constructor.
...
...
@@ -407,7 +409,9 @@ class Admin(object):
a single Flask application, you have to set a unique endpoint name for each instance.
:param static_url_path:
Static URL Path. If provided, this specifies the default path to the static url directory for
all its views. Can be overriden in view configuration.
all its views. Can be overridden in view configuration.
:param base_template:
Override base HTML template for all static views. Defaults to `admin/base.html`.
"""
self
.
app
=
app
...
...
@@ -427,6 +431,7 @@ class Admin(object):
self
.
url
=
url
or
self
.
index_view
.
url
self
.
static_url_path
=
static_url_path
self
.
subdomain
=
subdomain
self
.
base_template
=
base_template
or
'admin/base.html'
# Add predefined index view
self
.
add_view
(
self
.
index_view
)
...
...
flask_admin/templates/admin/base.html
0 → 100644
View file @
3d957d9f
<!DOCTYPE html>
<html>
<head>
<title>
{% block title %}{% if admin_view.category %}{{ admin_view.category }} - {% endif %}{{ admin_view.name }} - {{ admin_view.admin.name }}{% endblock %}
</title>
{% block head_meta %}
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"description"
content=
""
>
<meta
name=
"author"
content=
""
>
{% endblock %}
{% block head_css %}
<link
href=
"{{ url_for('admin.static', filename='bootstrap/css/bootstrap.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='bootstrap/css/bootstrap-responsive.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='css/admin.css') }}"
rel=
"stylesheet"
>
{% endblock %}
{% block head %}
{% endblock %}
</head>
<body>
{% block page_body %}
<div
class=
"navbar navbar-fixed-top"
>
<div
class=
"navbar-inner"
>
<div
class=
"container"
>
{% block brand %}
<span
class=
"brand"
>
{{ admin_view.admin.name }}
</span>
{% endblock %}
<ul
class=
"nav"
>
{% for item in admin_view.admin.menu() %}
{% if item.is_category() %}
{% set children = item.get_children() %}
{% if children %}
{% if item.is_active(admin_view) %}
<li
class=
"active dropdown"
>
{% else %}
<li
class=
"dropdown"
>
{% endif %}
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
{{ item.name }}
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
{% for child in children %}
{% if child.is_active(admin_view) %}
<li
class=
"active"
>
{% else %}
<li>
{% endif %}
<a
href=
"{{ child.get_url() }}"
>
{{ child.name }}
</a>
</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% else %}
{% if item.is_accessible() %}
{% if item.is_active(admin_view) %}
<li
class=
"active"
>
{% else %}
<li>
{% endif %}
<a
href=
"{{ item.get_url() }}"
>
{{ item.name }}
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
<ul
class=
"nav pull-right"
>
{% for item in admin_view.admin.menu_links() %}
{% if item.is_accessible() %}
<li>
<a
href=
"{{ item.get_url() }}"
>
{{ item.name }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
</div>
{% with messages = get_flashed_messages(with_categories=True) %}
{% if messages %}
{% for category, m in messages %}
{% if category == 'error' %}
<div
class=
"alert alert-error"
>
{% else %}
<div
class=
"alert"
>
{% endif %}
<a
href=
"#"
class=
"close"
data-dismiss=
"alert"
>
x
</a>
{{ m }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div
class=
"container"
>
{% block body %}{% endblock %}
</div>
{% endblock %}
<script
src=
"{{ url_for('admin.static', filename='js/jquery-1.8.3.min.js') }}"
type=
"text/javascript"
></script>
<script
src=
"{{ url_for('admin.static', filename='bootstrap/js/bootstrap.min.js') }}"
type=
"text/javascript"
></script>
<script
src=
"{{ url_for('admin.static', filename='select2/select2.min.js') }}"
type=
"text/javascript"
></script>
{% block tail %}
{% endblock %}
</body>
</html>
flask_admin/templates/admin/master.html
View file @
3d957d9f
<!DOCTYPE html>
<html>
<head>
<title>
{% block title %}{% if admin_view.category %}{{ admin_view.category }} - {% endif %}{{ admin_view.name }} - {{ admin_view.admin.name }}{% endblock %}
</title>
{% block head_meta %}
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"description"
content=
""
>
<meta
name=
"author"
content=
""
>
{% endblock %}
{% block head_css %}
<link
href=
"{{ url_for('admin.static', filename='bootstrap/css/bootstrap.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='bootstrap/css/bootstrap-responsive.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='css/admin.css') }}"
rel=
"stylesheet"
>
{% endblock %}
{% block head %}
{% endblock %}
</head>
<body>
{% block page_body %}
<div
class=
"navbar navbar-fixed-top"
>
<div
class=
"navbar-inner"
>
<div
class=
"container"
>
{% block brand %}
<span
class=
"brand"
>
{{ admin_view.admin.name }}
</span>
{% endblock %}
<ul
class=
"nav"
>
{% for item in admin_view.admin.menu() %}
{% if item.is_category() %}
{% set children = item.get_children() %}
{% if children %}
{% if item.is_active(admin_view) %}
<li
class=
"active dropdown"
>
{% else %}
<li
class=
"dropdown"
>
{% endif %}
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
{{ item.name }}
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
{% for child in children %}
{% if child.is_active(admin_view) %}
<li
class=
"active"
>
{% else %}
<li>
{% endif %}
<a
href=
"{{ child.get_url() }}"
>
{{ child.name }}
</a>
</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% else %}
{% if item.is_accessible() %}
{% if item.is_active(admin_view) %}
<li
class=
"active"
>
{% else %}
<li>
{% endif %}
<a
href=
"{{ item.get_url() }}"
>
{{ item.name }}
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
<ul
class=
"nav pull-right"
>
{% for item in admin_view.admin.menu_links() %}
{% if item.is_accessible() %}
<li>
<a
href=
"{{ item.get_url() }}"
>
{{ item.name }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
</div>
{% with messages = get_flashed_messages(with_categories=True) %}
{% if messages %}
{% for category, m in messages %}
{% if category == 'error' %}
<div
class=
"alert alert-error"
>
{% else %}
<div
class=
"alert"
>
{% endif %}
<a
href=
"#"
class=
"close"
data-dismiss=
"alert"
>
x
</a>
{{ m }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div
class=
"container"
>
{% block body %}{% endblock %}
</div>
{% endblock %}
<script
src=
"{{ url_for('admin.static', filename='js/jquery-1.8.3.min.js') }}"
type=
"text/javascript"
></script>
<script
src=
"{{ url_for('admin.static', filename='bootstrap/js/bootstrap.min.js') }}"
type=
"text/javascript"
></script>
<script
src=
"{{ url_for('admin.static', filename='select2/select2.min.js') }}"
type=
"text/javascript"
></script>
{% block tail %}
{% endblock %}
</body>
</html>
{% extends admin_base_template %}
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