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
96f51f31
Commit
96f51f31
authored
Mar 21, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Layout sample and some template modifications
parent
da1e16a2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
120 additions
and
110 deletions
+120
-110
simple.py
examples/layout/simple.py
+4
-1
layout.css
examples/layout/static/layout.css
+43
-1
create.html
examples/layout/templates/create.html
+16
-1
edit.html
examples/layout/templates/edit.html
+16
-1
layout.html
examples/layout/templates/layout.html
+8
-3
list.html
examples/layout/templates/list.html
+14
-87
actions.html
flask_admin/templates/admin/actions.html
+1
-3
create.html
flask_admin/templates/admin/model/create.html
+4
-4
layout.html
flask_admin/templates/admin/model/layout.html
+11
-9
list.html
flask_admin/templates/admin/model/list.html
+3
-0
No files found.
examples/layout/simple.py
View file @
96f51f31
...
@@ -41,6 +41,9 @@ class CustomView(ModelView):
...
@@ -41,6 +41,9 @@ class CustomView(ModelView):
create_template
=
'create.html'
create_template
=
'create.html'
edit_template
=
'edit.html'
edit_template
=
'edit.html'
column_searchable_list
=
(
'name'
,)
column_filters
=
(
'name'
,)
# Flask views
# Flask views
@
app
.
route
(
'/'
)
@
app
.
route
(
'/'
)
...
@@ -61,4 +64,4 @@ if __name__ == '__main__':
...
@@ -61,4 +64,4 @@ if __name__ == '__main__':
# Start app
# Start app
app
.
debug
=
True
app
.
debug
=
True
app
.
run
(
'0.0.0.0'
,
800
0
)
app
.
run
(
'0.0.0.0'
,
800
1
)
examples/layout/static/layout.css
View file @
96f51f31
.btn-title
{
body
{
background
:
#EEE
;
}
#content
{
background
:
white
;
border
:
1px
solid
#CCC
;
padding
:
12px
;
}
#brand
{
float
:
left
;
font-weight
:
300
;
margin
:
0
;
}
.search-form
{
margin
:
0
5px
;
}
.search-form
form
{
margin
:
0
;
}
.btn-menu
{
margin
:
4px
5px
0
0
;
float
:
right
;
float
:
right
;
}
.btn-menu
a
,
.btn-menu
input
{
padding
:
7px
16px
!important
;
border-radius
:
0
!important
;
}
.model-list
{
border-radius
:
0
;
}
.form-buttons
a
,
.form-buttons
input
,
.form-buttons
button
{
border-radius
:
0
;
}
.nav-pills
li
>
a
{
border-radius
:
0
;
}
}
\ No newline at end of file
examples/layout/templates/create.html
View file @
96f51f31
{% extends 'admin/model/create.html' %}
{% extends 'admin/model/create.html' %}
\ No newline at end of file
{% block brand %}
<h2
id=
"brand"
>
Create {{ admin_view.name|capitalize }}
</h2>
<div
class=
"clearfix"
></div>
<hr>
{% endblock %}
{% block body %}
{% call lib.form_tag() %}
{{ lib.render_form_fields(form, widget_args=form_widget_args) }}
<div
class=
"form-buttons"
>
{{ lib.render_form_buttons(return_url, extra()) }}
</div>
{% endcall %}
{% endblock %}
examples/layout/templates/edit.html
View file @
96f51f31
{% extends 'admin/model/edit.html' %}
{% extends 'admin/model/edit.html' %}
\ No newline at end of file
{% block brand %}
<h2
id=
"brand"
>
Edit {{ admin_view.name|capitalize }}
</h2>
<div
class=
"clearfix"
></div>
<hr>
{% endblock %}
{% block body %}
{% call lib.form_tag() %}
{{ lib.render_form_fields(form, widget_args=form_widget_args) }}
<div
class=
"form-buttons"
>
{{ lib.render_form_buttons(return_url) }}
</div>
{% endcall %}
{% endblock %}
examples/layout/templates/layout.html
View file @
96f51f31
...
@@ -16,9 +16,14 @@
...
@@ -16,9 +16,14 @@
</ul>
</ul>
</div>
</div>
<div
class=
"span10"
>
<div
class=
"span10"
>
{% block brand %}
<h1>
{{ admin_view.name|capitalize }}
</h1>
{% endblock %}
<div
id=
"content"
>
{{ layout.messages() }}
{% block brand %}
{% block body %}{% endblock %}
<h2
id=
"brand"
>
{{ admin_view.name|capitalize }}
</h2>
<div
class=
"clearfix"
></div>
{% endblock %}
{{ layout.messages() }}
{% block body %}{% endblock %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
examples/layout/templates/list.html
View file @
96f51f31
...
@@ -2,106 +2,33 @@
...
@@ -2,106 +2,33 @@
{% import 'admin/model/layout.html' as model_layout with context %}
{% import 'admin/model/layout.html' as model_layout with context %}
{% block brand %}
{% block brand %}
<h
1
style=
"float: left"
>
{{ admin_view.name|capitalize }} model
</h1
>
<h
2
id=
"brand"
>
{{ admin_view.name|capitalize }} list
</h2
>
{% if admin_view.can_create %}
{% if admin_view.can_create %}
<a
href=
"{{ url_for('.create_view', url=return_url) }}"
class=
"btn btn-primary btn-title"
>
{{ _gettext('Create') }}
</a>
<div
class=
"btn-menu"
>
<a
href=
"{{ url_for('.create_view', url=return_url) }}"
class=
"btn btn-primary pull-right"
>
{{ _gettext('Create') }}
</a>
</div>
{% endif %}
{% endif %}
{% if filter_groups %}
{% if filter_groups %}
{{ model_layout.filter_options() }}
<div
class=
"btn-group btn-menu"
>
{{ model_layout.filter_options(btn_class='btn dropdown-toggle btn-title') }}
</div>
{% endif %}
{% endif %}
{% if actions %}
{% if actions %}
<div
class=
"btn-group btn-
title
"
>
<div
class=
"btn-group btn-
menu
"
>
{{ actionlib.dropdown(actions) }}
{{ actionlib.dropdown(actions
, btn_class='btn dropdown-toggle btn-title'
) }}
</div>
</div>
{% endif %}
{% endif %}
{% if search_supported %}
{% if search_supported %}
{{ model_layout.search_form() }}
<div
class=
"search-form btn-menu"
>
{{ model_layout.search_form(input_class='span2 btn-title') }}
</div>
{% endif %}
{% endif %}
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
<hr>
<hr>
{% endblock %}
{% endblock %}
{% block body %}
{% block model_menu_bar %}
{% if filter_groups %}
{% endblock %}
{{ model_layout.filter_form() }}
\ No newline at end of file
{% endif %}
<table
class=
"table table-striped table-bordered model-list"
>
<thead>
<tr>
{% block list_header scoped %}
{% if actions %}
<th
class=
"span1"
>
<input
type=
"checkbox"
name=
"rowtoggle"
class=
"action-rowtoggle"
/>
</th>
{% endif %}
<th
class=
"span1"
>
</th>
{% set column = 0 %}
{% for c, name in list_columns %}
<th>
{% if admin_view.is_sortable(c) %}
{% if sort_column == column %}
<a
href=
"{{ sort_url(column, True) }}"
>
{{ name }}
{% if sort_desc %}
<i
class=
"icon-chevron-up"
></i>
{% else %}
<i
class=
"icon-chevron-down"
></i>
{% endif %}
</a>
{% else %}
<a
href=
"{{ sort_url(column) }}"
>
{{ name }}
</a>
{% endif %}
{% else %}
{{ name }}
{% endif %}
{% if admin_view.column_descriptions.get(c) %}
<a
class=
"icon-question-sign"
title=
"{{ admin_view.column_descriptions[c] }}"
href=
"#"
data-role=
"tooltip"
></a>
{% endif %}
</th>
{% set column = column + 1 %}
{% endfor %}
{% endblock %}
</tr>
</thead>
{% for row in data %}
<tr>
{% block list_row scoped %}
{% if actions %}
<td>
<input
type=
"checkbox"
name=
"rowid"
class=
"action-checkbox"
value=
"{{ get_pk_value(row) }}"
/>
</td>
{% endif %}
<td>
{% block list_row_actions scoped %}
{%- if admin_view.can_edit -%}
<a
class=
"icon"
href=
"{{ url_for('.edit_view', id=get_pk_value(row), url=return_url) }}"
>
<i
class=
"icon-pencil"
></i>
</a>
{%- endif -%}
{%- if admin_view.can_delete -%}
<form
class=
"icon"
method=
"POST"
action=
"{{ url_for('.delete_view', id=get_pk_value(row), url=return_url) }}"
>
<button
onclick=
"return confirm('{{ _gettext('You sure you want to delete this item?') }}');"
>
<i
class=
"icon-remove"
></i>
</button>
</form>
{%- endif -%}
{% endblock %}
</td>
{% for c, name in list_columns %}
<td>
{{ get_value(row, c) }}
</td>
{% endfor %}
{% endblock %}
</tr>
{% endfor %}
</table>
{{ lib.pager(page, num_pages, pager_url) }}
{{ actionlib.form(actions, url_for('.action_view')) }}
{% endblock %}
flask_admin/templates/admin/actions.html
View file @
96f51f31
{% macro dropdown(actions, btn_class='dropdown-toggle') -%}
{% macro dropdown(actions, btn_class='dropdown-toggle') -%}
<a
class=
"{{ btn_class }}"
data-toggle=
"dropdown"
href=
"#"
>
<a
class=
"{{ btn_class }}"
data-toggle=
"dropdown"
href=
"#"
>
{{ _gettext('With selected') }}
<b
class=
"caret"
></b></a>
{{ _gettext('With selected') }}
<b
class=
"caret"
></b>
</a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
{% for p in actions %}
{% for p in actions %}
<li>
<li>
...
...
flask_admin/templates/admin/model/create.html
View file @
96f51f31
{% extends 'admin/master.html' %}
{% extends 'admin/master.html' %}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% macro extra() %}
<input
name=
"_add_another"
type=
"submit"
class=
"btn btn-large"
value=
"{{ _gettext('Save and Add') }}"
/>
{% endmacro %}
{% block head %}
{% block head %}
<link
href=
"{{ url_for('admin.static', filename='select2/select2.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='select2/select2.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='css/datepicker.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='css/datepicker.css') }}"
rel=
"stylesheet"
>
...
@@ -16,10 +20,6 @@
...
@@ -16,10 +20,6 @@
</li>
</li>
</ul>
</ul>
{% macro extra() %}
<input
name=
"_add_another"
type=
"submit"
class=
"btn btn-large"
value=
"{{ _gettext('Save and Add') }}"
/>
{% endmacro %}
{% call lib.form_tag() %}
{% call lib.form_tag() %}
{{ lib.render_form_fields(form, widget_args=form_widget_args) }}
{{ lib.render_form_fields(form, widget_args=form_widget_args) }}
{{ lib.render_form_buttons(return_url, extra()) }}
{{ lib.render_form_buttons(return_url, extra()) }}
...
...
flask_admin/templates/admin/model/layout.html
View file @
96f51f31
{% macro filter_options() %}
{% macro filter_options(
btn_class='dropdown-toggle'
) %}
<a
class=
"
dropdown-toggle
"
data-toggle=
"dropdown"
href=
"#"
>
<a
class=
"
{{ btn_class }}
"
data-toggle=
"dropdown"
href=
"#"
>
{{ _gettext('Add Filter') }}
<b
class=
"caret"
></b>
{{ _gettext('Add Filter') }}
<b
class=
"caret"
></b>
</a>
</a>
<ul
class=
"dropdown-menu field-filters"
>
<ul
class=
"dropdown-menu field-filters"
>
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
</form>
</form>
{% endmacro %}
{% endmacro %}
{% macro search_form() %}
{% macro search_form(
input_class="search-query span2"
) %}
<form
method=
"GET"
action=
"{{ return_url }}"
class=
"search-form"
>
<form
method=
"GET"
action=
"{{ return_url }}"
class=
"search-form"
>
{% if sort_column is not none %}
{% if sort_column is not none %}
<input
type=
"hidden"
name=
"sort"
value=
"{{ sort_column }}"
></input>
<input
type=
"hidden"
name=
"sort"
value=
"{{ sort_column }}"
></input>
...
@@ -55,11 +55,13 @@
...
@@ -55,11 +55,13 @@
{% if sort_desc %}
{% if sort_desc %}
<input
type=
"hidden"
name=
"desc"
value=
"{{ sort_desc }}"
></input>
<input
type=
"hidden"
name=
"desc"
value=
"{{ sort_desc }}"
></input>
{% endif %}
{% endif %}
<input
type=
"text"
name=
"search"
value=
"{{ search or '' }}"
class=
"search-query span2"
placeholder=
"{{ _gettext('Search') }}"
></input>
<div
class=
"input-append"
>
{% if search %}
<input
type=
"text"
name=
"search"
value=
"{{ search or '' }}"
class=
"{{ input_class }}"
placeholder=
"{{ _gettext('Search') }}"
></input>
<a
href=
"{{ clear_search_url }}"
class=
"clear"
>
{% if search %}
<i
class=
"icon-remove"
></i>
<a
href=
"{{ clear_search_url }}"
class=
"clear add-on"
>
</a>
<i
class=
"icon-remove"
></i>
{% endif %}
</a>
{% endif %}
</div>
</form>
</form>
{% endmacro %}
{% endmacro %}
flask_admin/templates/admin/model/list.html
View file @
96f51f31
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
{% import 'admin/actions.html' as actionlib with context %}
{% import 'admin/actions.html' as actionlib with context %}
{% block head %}
{% block head %}
{{ super() }}
<link
href=
"{{ url_for('admin.static', filename='select2/select2.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='select2/select2.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='css/datepicker.css') }}"
rel=
"stylesheet"
>
<link
href=
"{{ url_for('admin.static', filename='css/datepicker.css') }}"
rel=
"stylesheet"
>
{% endblock %}
{% endblock %}
...
@@ -44,6 +45,7 @@
...
@@ -44,6 +45,7 @@
{{ model_layout.filter_form() }}
{{ model_layout.filter_form() }}
{% endif %}
{% endif %}
{% block model_list_table %}
<table
class=
"table table-striped table-bordered model-list"
>
<table
class=
"table table-striped table-bordered model-list"
>
<thead>
<thead>
<tr>
<tr>
...
@@ -117,6 +119,7 @@
...
@@ -117,6 +119,7 @@
{% endfor %}
{% endfor %}
</table>
</table>
{{ lib.pager(page, num_pages, pager_url) }}
{{ lib.pager(page, num_pages, pager_url) }}
{% endblock %}
{{ actionlib.form(actions, url_for('.action_view')) }}
{{ actionlib.form(actions, url_for('.action_view')) }}
{% endblock %}
{% endblock %}
...
...
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