forked from pallets-eco/flask-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated examples, added wysiwyg example
- Loading branch information
Showing
20 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This example shows how to integrate Flask-Login authentication with the Flask-Admin using MongoEngine backend. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This example shows how to integrate Flask-Login authentication with the Flask-Admin using SQLAlchemy backend. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This example show how to translate Flask-Admin into different language using customized version of the `Flask-Babel <https://github.com/mrjoes/flask-babel>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Simple file management interface example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
External menu links example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Example which shows how to integrate Flask `MethodView` with Flask-Admin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MongoEngine model backend integration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This example shows how to create two separate instances of Flask-Admin for one Flask application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Peewee model backend integration example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PyMongo model backend integration example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Simple Flask-Admin examples used by the quickstart tutorial. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SQLAlchemy model backend integration example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Simple CKEditor integration example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
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__) | ||
|
||
# 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) | ||
|
||
|
||
# Define wtforms widget and field | ||
class CKTextAreaWidget(wtf.TextArea): | ||
def __call__(self, field, **kwargs): | ||
kwargs.setdefault('class_', 'ckeditor') | ||
return super(CKTextAreaWidget, self).__call__(field, **kwargs) | ||
|
||
|
||
class CKTextAreaField(wtf.TextAreaField): | ||
widget = CKTextAreaWidget() | ||
|
||
|
||
# Model | ||
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 PageAdmin(sqlamodel.ModelView): | ||
form_overrides = dict(text=CKTextAreaField) | ||
|
||
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) | ||
|
||
# Add views | ||
admin.add_view(PageAdmin(Page, db.session)) | ||
|
||
# Create DB | ||
db.create_all() | ||
|
||
# Start app | ||
app.debug = True | ||
app.run('0.0.0.0', 8000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends 'admin/model/create.html' %} | ||
|
||
{% block tail %} | ||
{{ super() }} | ||
<script src="http://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.0.1/ckeditor.js"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends 'admin/model/create.html' %} | ||
|
||
{% block tail %} | ||
{{ super() }} | ||
<script src="http://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.0.1/ckeditor.js"></script> | ||
{% endblock %} |