Skip to content

Commit 0e32fc2

Browse files
authored
Merge pull request pallets-eco#1 from flask-admin/master
pull master
2 parents 619699b + bf17b7a commit 0e32fc2

File tree

227 files changed

+2036
-2814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+2036
-2814
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ addons:
3333
services:
3434
- postgresql
3535
- mongodb
36+
- docker
3637

3738
before_script:
3839
- psql -U postgres -c 'CREATE DATABASE flask_admin_test;'
3940
- psql -U postgres -c 'CREATE EXTENSION postgis;' flask_admin_test
4041
- psql -U postgres -c 'CREATE EXTENSION hstore;' flask_admin_test
42+
- docker run --restart always -d -e executable=blob -p 10000:10000 --tmpfs /opt/azurite/folder arafato/azurite:2.6.5
4143

4244
install:
4345
- pip install tox

README.rst

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,28 @@ Flask-Admin is an active project, well-tested and production ready.
3838

3939
Examples
4040
--------
41-
Several usage examples are included in the */examples* folder. Please feel free to add your own examples, or improve
42-
on some of the existing ones, and then submit them via GitHub as a *pull-request*.
41+
Several usage examples are included in the */examples* folder. Please add your own, or improve
42+
on the existing examples, and submit a *pull-request*.
4343

44-
You can see some of these examples in action at `http://examples.flask-admin.org <http://examples.flask-admin.org/>`_.
45-
To run the examples on your local environment, one at a time, do something like::
44+
To run the examples in your local environment::
4645

47-
cd flask-admin
48-
python examples/simple/app.py
46+
1. Clone the repository::
47+
48+
git clone https://github.com/flask-admin/flask-admin.git
49+
cd flask-admin
50+
51+
2. Create and activate a virtual environment::
52+
53+
virtualenv env -p python3
54+
source env/bin/activate
55+
56+
3. Install requirements::
57+
58+
pip install -r 'examples/sqla/requirements.txt'
59+
60+
4. Run the application::
61+
62+
python examples/sqla/app.py
4963

5064
Documentation
5165
-------------
@@ -91,7 +105,11 @@ You should see output similar to::
91105

92106
For all the tests to pass successfully, you'll need Postgres & MongoDB to be running locally. For Postgres::
93107

108+
> psql postgres
94109
CREATE DATABASE flask_admin_test;
110+
\q
111+
112+
> psql flask_admin_test
95113
CREATE EXTENSION postgis;
96114
CREATE EXTENSION hstore;
97115

@@ -100,7 +118,8 @@ You can also run the tests on multiple environments using *tox*.
100118
3rd Party Stuff
101119
---------------
102120

103-
Flask-Admin is built with the help of `Bootstrap <http://getbootstrap.com/>`_ and `Select2 <https://github.com/ivaynberg/select2>`_.
121+
Flask-Admin is built with the help of `Bootstrap <http://getbootstrap.com/>`_, `Select2 <https://github.com/ivaynberg/select2>`_
122+
and `Bootswatch <http://bootswatch.com/>`_.
104123

105124
If you want to localize your application, install the `Flask-BabelEx <https://pypi.python.org/pypi/Flask-BabelEx>`_ package.
106125

doc/_templates/sidebarintro.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ <h3>Useful Links</h3>
22
<ul>
33
<li><a href="http://flask.pocoo.org/" target="_blank">Flask</a></li>
44
<li><a href="http://github.com/flask-admin/flask-admin" target="_blank">Flask-Admin @ github</a></li>
5-
<li><a href="http://examples.flask-admin.org/" target="_blank">Flask-Admin Examples</a></li>
65
</ul>
76

87
<a class="github" href="http://github.com/flask-admin/flask-admin" target="_blank"><img style="position: fixed; top: 0; right: 0; border: 0;"

doc/advanced.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Enabling localization is simple:
3434

3535
#. Initialize Flask-BabelEx by creating instance of `Babel` class::
3636

37-
from flask import app
37+
from flask import Flask
3838
from flask_babelex import Babel
3939

4040
app = Flask(__name__)
@@ -164,7 +164,7 @@ Image handling also requires you to have `Pillow <https://pypi.python.org/pypi/P
164164
installed if you need to do any processing on the image files.
165165

166166
Have a look at the example at
167-
https://github.com/flask-admin/Flask-Admin/tree/master/examples/forms.
167+
https://github.com/flask-admin/Flask-Admin/tree/master/examples/forms-files-images.
168168

169169
If you are using the MongoEngine backend, Flask-Admin supports GridFS-backed image and file uploads through WTForms fields. Documentation can be found at :mod:`flask_admin.contrib.mongoengine.fields`.
170170

@@ -544,4 +544,3 @@ While the wrapped function should accept only one parameter - `ids`::
544544
raise
545545

546546
flash(gettext('Failed to approve users. %(error)s', error=str(ex)), 'error')
547-

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ API
1515
mod_actions
1616

1717
mod_contrib_sqla
18+
mod_contrib_sqla_fields
1819
mod_contrib_mongoengine
1920
mod_contrib_mongoengine_fields
2021
mod_contrib_peewee

doc/api/mod_contrib_sqla_fields.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
``flask_admin.contrib.sqla.fields``
2+
===================================
3+
4+
.. automodule:: flask_admin.contrib.sqla.fields
5+
6+
.. autoclass:: QuerySelectField
7+
:members:
8+
9+
.. autoclass:: QuerySelectMultipleField
10+
:members:
11+
12+
.. autoclass:: CheckboxListField
13+
:members:

doc/changelog.rst

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
Changelog
22
=========
33

4+
1.5.3
5+
-----
6+
7+
* Fixed XSS vulnerability
8+
* Support nested categories in the navbar menu
9+
* SQLAlchemy
10+
* sort on multiple columns with `column_default_sort`
11+
* sort on related models in `column_sortable_list`
12+
* fix: inline model forms can now also be used for models with multiple primary keys
13+
* support for using mapped `column_property`
14+
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
15+
* Specify `minimum_input_length` for ajax widget
16+
* Peewee: support composite keys
17+
* MongoEngine: when searching/filtering the input is now regarded as case-insensitive by default
18+
* FileAdmin
19+
* handle special characters in filename
20+
* fix a bug with listing directories on Windows
21+
* avoid raising an exception when unknown sort parameter is encountered
22+
* WTForms 3 support
23+
24+
1.5.2
25+
-----
26+
27+
* Fixed XSS vulnerability
28+
* Fixed Peewee support
29+
* Added detail view column formatters
30+
* Updated Flask-Login example to work with the newer version of the library
31+
* Various SQLAlchemy-related fixes
32+
* Various Windows related fixes for the file admin
33+
34+
1.5.1
35+
-----
36+
37+
* Dropped Python 2.6 support
38+
* Fixed SQLAlchemy >= 1.2 compatibility
39+
* Fixed Pewee 3.0 compatibility
40+
* Fixed max year for a combo date inline editor
41+
* Lots of small bug fixes
42+
443
1.5.0
544
-----
645

@@ -13,7 +52,7 @@ Changelog
1352
- Added support for association proxies
1453
- Added support for remote hybrid properties filters
1554
- Added support for ARRAY column type
16-
* Localization-related fixes
55+
* Localization-related fixes
1756
* MongoEngine backend is now properly formats model labels
1857
* Improved Google App Engine support:
1958
- Added TextProperty, KeyProperty and SelectField support

doc/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ because they let you group together all of the usual
2323
*Create, Read, Update, Delete* (CRUD) view logic into a single, self-contained
2424
class for each of your models.
2525

26-
**What does it look like?** At http://examples.flask-admin.org/ you can see
27-
some examples of Flask-Admin in action, or browse through the `examples/`
28-
directory in the `GitHub repository <https://github.com/flask-admin/flask-admin>`_.
26+
**What does it look like?** Clone the `GitHub repository <https://github.com/flask-admin/flask-admin>`_
27+
and run the provided examples locally to get a feel for Flask-Admin. There are several to choose from
28+
in the `examples` directory.
2929

3030
.. toctree::
3131
:maxdepth: 2

doc/introduction.rst

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ The first step is to initialize an empty admin interface for your Flask app::
1818

1919
app = Flask(__name__)
2020

21+
# set optional bootswatch theme
22+
app.config['FLASK_ADMIN_SWATCH'] = 'cerulean'
23+
2124
admin = Admin(app, name='microblog', template_mode='bootstrap3')
2225
# Add administrative views here
2326

@@ -27,7 +30,8 @@ Here, both the *name* and *template_mode* parameters are optional. Alternatively
2730
you could use the :meth:`~flask_admin.base.Admin.init_app` method.
2831

2932
If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_,
30-
you should see an empty page with a navigation bar on top.
33+
you should see an empty page with a navigation bar on top. Customize the look by
34+
specifying a Bootswatch theme that suits your needs (see http://bootswatch.com/3/ for available swatches).
3135

3236
Adding Model Views
3337
------------------
@@ -156,12 +160,9 @@ Customizing Built-in Views
156160

157161
****
158162

159-
The built-in `ModelView` class is great for getting started quickly. But, you'll want
160-
to configure its functionality to suit your particular models. This is done by setting
161-
values for the configuration attributes that are made available in the `ModelView` class.
162-
163-
To specify some global configuration parameters, you can subclass `ModelView` and use that
164-
subclass when adding your models to the interface::
163+
When inheriting from `ModelView`, values can be specified for numerous
164+
configuration parameters. Use these to customize the views to suit your
165+
particular models::
165166

166167
from flask_admin.contrib.sqla import ModelView
167168

@@ -287,6 +288,28 @@ To **enable csv export** of the model view::
287288

288289
This will add a button to the model view that exports records, truncating at :attr:`~flask_admin.model.BaseModelView.export_max_rows`.
289290

291+
292+
Grouping Views
293+
==============
294+
When adding a view, specify a value for the `category` parameter
295+
to group related views together in the menu::
296+
297+
admin.add_view(UserView(User, db.session, category="Team"))
298+
admin.add_view(ModelView(Role, db.session, category="Team"))
299+
admin.add_view(ModelView(Permission, db.session, category="Team"))
300+
301+
This will create a top-level menu item named 'Team', and a drop-down containing
302+
links to the three views.
303+
304+
To nest related views within these drop-downs, use the `add_sub_category` method::
305+
306+
admin.add_sub_category(name="Links", parent_name="Team")
307+
308+
And to add arbitrary hyperlinks to the menu::
309+
310+
admin.add_link(MenuLink(name='Home Page', url='/', category='Links'))
311+
312+
290313
Adding Your Own Views
291314
=====================
292315

@@ -440,7 +463,7 @@ list_row_actions Row action cell with edit/remove/etc buttons
440463
empty_list_message Message that will be displayed if there are no models found
441464
======================= ============================================
442465

443-
Have a look at the `layout` example at https://github.com/flask-admin/flask-admin/tree/master/examples/layout
466+
Have a look at the `layout` example at https://github.com/flask-admin/flask-admin/tree/master/examples/custom-layout
444467
to see how you can take full stylistic control over the admin interface.
445468

446469
Environment Variables

examples/layout/README.rst renamed to examples/custom-layout/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ To run this example:
1414

1515
3. Install requirements::
1616

17-
pip install -r 'examples/layout/requirements.txt'
17+
pip install -r 'examples/custom-layout/requirements.txt'
1818

1919
4. Run the application::
2020

21-
python examples/layout/app.py
21+
python examples/custom-layout/app.py
2222

2323
The first time you run this example, a sample sqlite database gets populated automatically. To suppress this behaviour,
2424
comment the following lines in app.py:::
File renamed without changes.
File renamed without changes.

examples/layout_bootstrap3/templates/layout.html renamed to examples/custom-layout/templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% endblock %}
88

99
{% block page_body %}
10-
<div class="container">
10+
<div class="container-fluid">
1111
<div class="row">
1212
<div class="col-md-2" role="navigation">
1313
<ul class="nav nav-pills nav-stacked">

examples/file/README.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/file/app.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

examples/sqla-custom-filter/README.rst renamed to examples/forms-files-images/README.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
Example of custom filters for the SQLAlchemy backend.
1+
This example shows how you can::
2+
3+
* define your own custom forms by using form rendering rules
4+
* handle generic static file uploads
5+
* handle image uploads
6+
* turn a TextArea field into a rich WYSIWYG editor using WTForms and CKEditor
7+
* set up a Flask-Admin view as a Redis terminal
8+
29

310
To run this example:
411

@@ -14,11 +21,11 @@ To run this example:
1421

1522
3. Install requirements::
1623

17-
pip install -r 'examples/sqla-custom-filter/requirements.txt'
24+
pip install -r 'examples/forms-files-images/requirements.txt'
1825

1926
4. Run the application::
2027

21-
python examples/sqla-custom-filter/app.py
28+
python examples/forms-files-images/app.py
2229

2330
The first time you run this example, a sample sqlite database gets populated automatically. To suppress this behaviour,
2431
comment the following lines in app.py:::
File renamed without changes.

0 commit comments

Comments
 (0)