Example #1
0
def setup():
    connect('superadmin_test')
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['WTF_CSRF_ENABLED'] = False

    admin = Admin(app)

    return app, admin
def setup():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'

    db = SQLAlchemy(app)
    admin = Admin(app)

    return app, db, admin
Example #3
0

settings.configure(
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': 'mydatabase.sqlite',
        }
    }
)

app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'
app.config['WTF_CSRF_ENABLED'] = False

admin = Admin(app)

from flask_superadmin.model.backends.django.view import ModelAdmin
from django.db import models, DatabaseError
from examples.django.utils import install_models


class CustomModelView(ModelAdmin):
    def __init__(self, model, name=None, category=None, endpoint=None,
                 url=None, **kwargs):
        for k, v in kwargs.iteritems():
            setattr(self, k, v)

        super(CustomModelView, self).__init__(model, name, category, endpoint,
                                              url)
Example #4
0
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)
Example #5
0

@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('/')
Example #6
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)
Example #7
0
from flask import Flask
from flask_superadmin 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()
Example #8
0
from django.conf import settings

settings.configure(
    DATABASES={
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': 'mydatabase.sqlite',
        }
    })

app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'
app.config['WTF_CSRF_ENABLED'] = False

admin = Admin(app)

from flask_superadmin.model.backends.django.view import ModelAdmin
from django.db import models, DatabaseError
from examples.django.utils import install_models


class CustomModelView(ModelAdmin):
    def __init__(self,
                 model,
                 name=None,
                 category=None,
                 endpoint=None,
                 url=None,
                 **kwargs):
        for k, v in kwargs.iteritems():
Example #9
0
#-*- 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)
Example #10
0
from flask import Flask
from flask_superadmin import Admin

app = Flask(__name__)

admin = Admin(app)
app.run()
Example #11
0
    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)
Example #12
0
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)
Example #13
0
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)
Example #14
0
from flask_bootstrap import Bootstrap
from flask_nav import Nav, register_renderer
from config import config
from flask_sqlalchemy import SQLAlchemy
from flask_security import Security, SQLAlchemyUserDatastore
from flask_superadmin import Admin
from flask_misaka import Misaka

bootstrap = Bootstrap()
nav = Nav()
markdown = Misaka()

db = SQLAlchemy()
security = Security()
from .adminviews import ModelAdmin, AdminIndexView
admin = Admin(index_view=AdminIndexView())


def create_app(config_name='default'):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    nav.init_app(app)
    db.init_app(app)
    markdown.init_app(app)
    admin.init_app(app)

    from .models import User, Role, Post
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
Example #15
0
    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')
Example #16
0
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)
Example #17
0
from flask import Flask
from flask_superadmin 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()
Example #18
0
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)
Example #19
0
# Copyright 2013 Alexandre Bulté <alexandre[at]bulte[dot]net>
# 
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask_superadmin import Admin, AdminIndexView
from flask_superadmin.model.backends.mongoengine import ModelAdmin
from flask_login import current_user

from webapp import app
from .models import User, DummyContent

# Create customized model view class
class MyModelView(ModelAdmin):
    def is_accessible(self):
        return current_user.is_authenticated()


# Create customized index view class
class MyAdminIndexView(AdminIndexView):
    def is_accessible(self):
        return current_user.is_authenticated()

# Create admin
admin = Admin(app, 'Backoffice', index_view=MyAdminIndexView())

# Add view
admin.add_view(MyModelView(User))
admin.add_view(MyModelView(DummyContent))
Example #20
0
    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)