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
4f1df6d3
Commit
4f1df6d3
authored
Mar 21, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Layout sample wip
parent
f0f0738f
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
201 additions
and
5 deletions
+201
-5
simple.py
examples/layout/simple.py
+64
-0
layout.css
examples/layout/static/layout.css
+3
-0
create.html
examples/layout/templates/create.html
+1
-0
edit.html
examples/layout/templates/edit.html
+1
-0
layout.html
examples/layout/templates/layout.html
+25
-0
list.html
examples/layout/templates/list.html
+107
-0
simple.py
examples/wysiwyg/simple.py
+0
-5
No files found.
examples/layout/simple.py
0 → 100644
View file @
4f1df6d3
from
flask
import
Flask
from
flask.ext.sqlalchemy
import
SQLAlchemy
from
flask.ext
import
admin
,
wtf
from
flask.ext.admin.contrib.sqlamodel
import
ModelView
# Create application
app
=
Flask
(
__name__
)
# Create dummy secrey key so we can use sessions
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///dummy.sqlite'
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
# Models
class
User
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
Unicode
(
64
))
email
=
db
.
Column
(
db
.
Unicode
(
64
))
def
__unicode__
(
self
):
return
self
.
name
class
Page
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
Unicode
(
64
))
text
=
db
.
Column
(
db
.
UnicodeText
)
def
__unicode__
(
self
):
return
self
.
name
# Customized admin interface
class
CustomView
(
ModelView
):
list_template
=
'list.html'
create_template
=
'create.html'
edit_template
=
'edit.html'
# Flask views
@
app
.
route
(
'/'
)
def
index
():
return
'<a href="/admin/">Click me to get to Admin!</a>'
if
__name__
==
'__main__'
:
# Create admin
admin
=
admin
.
Admin
(
app
,
base_template
=
'layout.html'
)
# Add views
admin
.
add_view
(
CustomView
(
User
,
db
.
session
))
admin
.
add_view
(
CustomView
(
Page
,
db
.
session
))
# Create DB
db
.
create_all
()
# Start app
app
.
debug
=
True
app
.
run
(
'0.0.0.0'
,
8000
)
examples/layout/static/layout.css
0 → 100644
View file @
4f1df6d3
.btn-title
{
float
:
right
;
}
\ No newline at end of file
examples/layout/templates/create.html
0 → 100644
View file @
4f1df6d3
{% extends 'admin/model/create.html' %}
\ No newline at end of file
examples/layout/templates/edit.html
0 → 100644
View file @
4f1df6d3
{% extends 'admin/model/edit.html' %}
\ No newline at end of file
examples/layout/templates/layout.html
0 → 100644
View file @
4f1df6d3
{% import 'admin/layout.html' as layout with context -%}
{% extends 'admin/base.html' %}
{% block head_css %}
{{ super() }}
<link
href=
"{{ url_for('static', filename='layout.css') }}"
rel=
"stylesheet"
>
{% endblock %}
{% block page_body %}
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"span2"
>
<ul
class=
"nav nav-pills nav-stacked"
>
{{ layout.menu() }}
{{ layout.menu_links() }}
</ul>
</div>
<div
class=
"span10"
>
{% block brand %}
<h1>
{{ admin_view.name|capitalize }}
</h1>
{% endblock %}
{{ layout.messages() }}
{% block body %}{% endblock %}
</div>
</div>
</div>
{% endblock %}
examples/layout/templates/list.html
0 → 100644
View file @
4f1df6d3
{% extends 'admin/model/list.html' %}
{% import 'admin/model/layout.html' as model_layout with context %}
{% block brand %}
<h1
style=
"float: left"
>
{{ admin_view.name|capitalize }} model
</h1>
{% if admin_view.can_create %}
<a
href=
"{{ url_for('.create_view', url=return_url) }}"
class=
"btn btn-primary btn-title"
>
{{ _gettext('Create') }}
</a>
{% endif %}
{% if filter_groups %}
{{ model_layout.filter_options() }}
{% endif %}
{% if actions %}
<div
class=
"btn-group btn-title"
>
{{ actionlib.dropdown(actions) }}
</div>
{% endif %}
{% if search_supported %}
{{ model_layout.search_form() }}
{% endif %}
<div
class=
"clearfix"
></div>
<hr>
{% endblock %}
{% block body %}
{% if filter_groups %}
{{ model_layout.filter_form() }}
{% 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 %}
examples/wysiwyg/simple.py
View file @
4f1df6d3
import
datetime
from
sqlalchemy.ext.hybrid
import
hybrid_property
from
flask
import
Flask
from
flask.ext.sqlalchemy
import
SQLAlchemy
from
flask.ext
import
admin
,
wtf
from
flask.ext.admin.contrib
import
sqlamodel
from
flask.ext.admin.contrib.sqlamodel
import
filters
# Create application
app
=
Flask
(
__name__
)
...
...
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