class Tag(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode(64)) def __unicode__(self): return self.name # Flask views @app.route('/') def index(): return '<a href="/admin/">Click me to get to Admin!</a>' if __name__ == '__main__': # Create admin admin = Admin(app, 'Simple Models') # Add views admin.register(User, session=db.session) admin.register(Tag, session=db.session) admin.register(Post, session=db.session) # admin.add_view(sqlamodel.ModelView(Post, session=db.session)) # Create DB db.create_all() # Start app app.debug = True app.run('0.0.0.0', 8000)
msg.body = submit_msg mail.send(msg) flash('The condate was submitted ok and is in review!') return redirect(url_for('index')) ### admin views class ConventionAdmin(model.ModelAdmin): session = db.session fields = list_display = ('title', 'location', 'url', 'twitter','tags') class TagAdmin(model.ModelAdmin): session = db.session fields = list_display = ('title',) class CondateAdmin(model.ModelAdmin): session = db.session fields = ('convention', 'title', 'start_date', 'end_date', 'registration_opens', 'registration_closes', 'published', 'notes') list_display = ('title', 'start_date', 'end_date', 'registration_opens', 'registration_closes', 'published') admin = Admin(app) admin.register(Convention, ConventionAdmin) admin.register(Condate, CondateAdmin) admin.register(Tag, TagAdmin) ### fire up the mothership if __name__ == '__main__': app.debug = True app.run(host='0.0.0.0')
"admin_commission": dict(label=u"관리자 수수료", description="퍼센트 기준"), "master_commission": dict(label=u"마스터 수수료", description="퍼센트 기준"), "status": dict(label=u"상태", description=u"0 : 배차중, 1 : 작업중, 2 : 작업완료"), "created_at": dict(label=u"등록일자"), "updated_at": dict(label=u"정보 최종 업데이트"), } class OperatorAdminMatchModel(ModelAdmin): session = db_session list_display = ("id", "operator", "admin") search_fields = ("id", "operator", "admin") class RequestWithDrawModel(ModelAdmin): session = db_session list_display = ("user", "point", "is_active") search_fields = ("user", "point", "is_active") # set admin admin_ = SuperAdmin(app) admin_.register(Operator, OperatorModel) admin_.register(OperatorAdminMatch, OperatorAdminMatchModel) admin_.register(Order, OrderModel) admin_.register(Point, session=db_session) admin_.register(Address, session=db_session) admin_.register(Price, session=db_session) admin_.register(RequestWithdraw, RequestWithDrawModel)
@login_manager.user_loader def load_user(id): ret = User.query.filter(User.id == id).first() return ret # Create customized index view class class MyAdminIndexView(AdminIndexView): def is_accessible(self): return current_user.is_authenticated # initialize super admin admin = Admin(app, "TPOD Models", index_view=MyAdminIndexView()) admin.register(User, session=db.session) admin.register(Video, session=db.session) admin.register(Classifier, session=db.session) @app.route("/", methods=["GET", "POST"]) @login_required def index(): return redirect(url_for('video_page.list_video')) @app.route("/login", methods=["GET", "POST"]) def login(): if current_user and current_user.is_authenticated: return redirect('/') if request.method == 'POST':
from flask_login import LoginManager from flask_superadmin import Admin app = Flask(__name__) # Basic Flask configuration app.config.from_pyfile('config.py') # Flask-SQLAlchemy configuration db = SQLAlchemy(app) # Flask-Login configuration login_manager = LoginManager() login_manager.init_app(app) import trackapp.views import trackapp.models import trackapp.forms # Flask SuperAdmin admin = Admin(app) admin.register(models.Location, session=db.session) admin.register(models.User, session=db.session) admin.register(models.Address, session=db.session) admin.register(models.Zone, session=db.session) admin.register(models.Anchor, session=db.session) admin.register(models.Route, session=db.session) admin.register(models.Sesh, session=db.session) admin.register(models.Climb, session=db.session)
from brewapp import app, db from model import * from flask_superadmin import Admin, model admin = Admin(app) admin.register(Step, session=db.session) admin.register(RecipeBooks, session=db.session) admin.register(RecipeBookSteps, session=db.session) admin.register(Kettle, session=db.session) admin.register(Hardware, session=db.session) admin.register(Config, session=db.session) admin.register(Fermenter, session=db.session) admin.register(FermenterStep, session=db.session) admin.register(Hydrometer, session=db.session)
#-*- coding: utf-8 -*- import flask as fl from flask_superadmin import Admin, BaseView, model from misasa.app import app, db from misasa import settings from .models import PreRegistrationLog # Create admin admin = Admin(app, '5minLab') class PreRegistrationLogModel(model.ModelAdmin): session = db list_display = ['phone', 'parent', 'os_type'] def is_accessible(self): if fl.request.remote_addr in settings.VALID_IP_LIST: return True return False admin.register(PreRegistrationLog, PreRegistrationLogModel)
user_id = db.Column(db.Integer(), db.ForeignKey(User.id)) user = db.relationship(User, backref='posts') def __unicode__(self): return self.title # Flask views @app.route('/') def index(): return '<a href="/admin/">Click me to get to Admin!</a>' if __name__ == '__main__': # Create admin admin = Admin(app, 'Simple Models') admin.locale_selector(get_locale) # Add views admin.register(User, session=db.session) admin.register(Post, session=db.session) # Create DB db.create_all() # Start app app.debug = True app.run('0.0.0.0', 8000)
class Post(Document): user = ReferenceField(User) tags = ListField(StringField()) text = StringField() date = DateTimeField() complex = ListField(EmbeddedDocumentField(ComplexEmbedded)) # Flask views @app.route('/') def index(): return '<a href="/admin/">Click me to get to Admin!</a>' if __name__ == '__main__': # Create admin admin = Admin(app, 'Simple Models') class UserModel(model.ModelAdmin): list_display = ('username', 'email') # only = ('username',) # Register the models admin.register(User, UserModel) admin.register(Post) # Start app app.debug = True app.run('0.0.0.0', 8000)
date = models.DateField() user = models.ForeignKey(User) def __unicode__(self): return self.title # Flask views @app.route('/') def index(): return '<a href="/admin/">Click me to get to Admin!</a>' # Build the manifest of apps and models that are to be synchronized if __name__ == '__main__': # Create admin admin = Admin(app, 'Simple Models') # Add views admin.register(User) admin.register(Post) # Create tables in database if not exists try: install_models(User,Post) except: pass # Start app app.debug = True app.run('0.0.0.0', 8000)