Skip to content

Commit

Permalink
Quickstart docs update.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoes committed Mar 23, 2012
1 parent aa49961 commit de02527
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 3 deletions.
Binary file added doc/images/quickstart/quickstart_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/quickstart/quickstart_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/quickstart/quickstart_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/quickstart/quickstart_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/quickstart/quickstart_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 47 additions & 3 deletions doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ To start using Flask-AdminEx, you have to create `Admin` class instance and asso
app.run()

If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_,
you should see empty "Home" page with a navigation bar on top.
you should see empty "Home" page with a navigation bar on top

.. image:: images/quickstart/quickstart_1.png
:target: _images/quickstart_1.png

You can change application name by passing `name` parameter to the `Admin` class constructor::

Expand All @@ -68,7 +71,7 @@ Adding view
Now, lets add a view. To do this, you need to derive from `BaseView` class::

from flask import Flask
from flask.ext.adminex import Admin, BaseView
from flask.ext.adminex import Admin, BaseView, expose

class MyView(BaseView):
@expose('/')
Expand Down Expand Up @@ -102,6 +105,35 @@ All administrative pages should derive from the 'admin/master.html' to maintain

If you will refresh 'Hello' administrative page again you should see greeting in the content section.

.. image:: images/quickstart/quickstart_2.png
:width: 640
:target: _images/quickstart_2.png

You're not limited to top level menu. It is possible to pass category name and it will be used as a
top menu item. For example::

from flask import Flask
from flask.ext.adminex import Admin, BaseView, expose

class MyView(BaseView):
@expose('/')
def index(self):
return self.render('index.html')

app = Flask(__name__)

admin = Admin(app)
admin.add_view(MyView(name='Hello 1', endpoint='test1', category='Test'))
admin.add_view(MyView(name='Hello 2', endpoint='test2', category='Test'))
admin.add_view(MyView(name='Hello 3', endpoint='test3', category='Test'))
app.run()

Will look like this:

.. image:: images/quickstart/quickstart_3.png
:width: 640
:target: _images/quickstart_3.png

Authentication
--------------

Expand Down Expand Up @@ -130,7 +162,7 @@ prefix to get URL to a local view::
class MyView(BaseView):
@expose('/')
def index(self)
# Get URL for the `test` view method
# Get URL for the test view method
url = url_for('.test')
return self.render('index.html', url=url)

Expand Down Expand Up @@ -174,6 +206,12 @@ Flask-AdminEx comes with built-in SQLAlchemy model administrative interface. It

This will create administrative interface for `User` model with default settings.

Here is how default list view looks like:

.. image:: images/quickstart/quickstart_4.png
:width: 640
:target: _images/quickstart_4.png

If you want to customize model views, you have two options:

1. Change behavior by overriding public properties that control how view works
Expand Down Expand Up @@ -218,6 +256,12 @@ Here is simple example::
path = op.join(op.dirname(__file__), 'static')
admin.add_view(path, '/static/', name='Static Files')

Sample screenshot:

.. image:: images/quickstart/quickstart_5.png
:width: 640
:target: _images/quickstart_5.png

You can disable uploads, disable file or directory deletion, restrict file uploads to certain types and so on.
Check :mod:`flask.ext.adminex.ext.fileadmin` documentation on how to do it.

Expand Down
8 changes: 8 additions & 0 deletions examples/quickstart/first.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask
from flask.ext.adminex import Admin


app = Flask(__name__)

admin = Admin(app)
app.run()
15 changes: 15 additions & 0 deletions examples/quickstart/second.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import Flask
from flask.ext.adminex import Admin, BaseView, expose


class MyView(BaseView):
@expose('/')
def index(self):
return self.render('index.html')

app = Flask(__name__)

admin = Admin(app)
admin.add_view(MyView(name='Hello'))

app.run()
4 changes: 4 additions & 0 deletions examples/quickstart/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends 'admin/master.html' %}
{% block body %}
Hello World from MyView!
{% endblock %}
15 changes: 15 additions & 0 deletions examples/quickstart/third.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import Flask
from flask.ext.adminex import Admin, BaseView, expose

class MyView(BaseView):
@expose('/')
def index(self):
return self.render('index.html')

app = Flask(__name__)

admin = Admin(app)
admin.add_view(MyView(name='Hello 1', endpoint='test1', category='Test'))
admin.add_view(MyView(name='Hello 2', endpoint='test2', category='Test'))
admin.add_view(MyView(name='Hello 3', endpoint='test3', category='Test'))
app.run()

0 comments on commit de02527

Please sign in to comment.