from sqlalchemy.schema import CreateTable

from app.core.env import DB
from app.models.datas import BibDatasTypes, TReleasedDatas
from app.models.dynamic_content import BibDynamicPagesCategory, TDynamicPages
from app.models.ref_geo import LAreasTypeSelection
from app.models.taxonomy import (
    BibRedlistCategories,
    BibRedlistSource,
    TMaxThreatenedStatus,
    TRedlist,
)

from .env import admin

admin.add_view(rediscli.RedisCli(Redis()))


def create_tables(db):
    """[summary]

    Args:
        db ([type]): [description]
    """
    db = db
    tables = [
        TDynamicPages.__table__,
        BibDynamicPagesCategory.__table__,
        TReleasedDatas.__table__,
        BibDatasTypes.__table__,
        LAreasTypeSelection.__table__,
Beispiel #2
0

@app.route('/')
def index():
    return '<a href="/admin/">Click me to get to Admin!</a>'


if __name__ == '__main__':
    import logging
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)

    admin = admin.Admin(app, name='RBC Admin', template_mode='bootstrap3')

    admin.add_view(UserAdmin(User))
    admin.add_view(PostAdmin(Post))
    admin.add_view(ZoneAdmin(Zone))
    admin.add_view(NoduleAdmin(Nodule))
    admin.add_view(ComponentAdmin(Component))
    admin.add_view(JobAdmin(Job))
    admin.add_view(rediscli.RedisCli(Redis(host="dmip")))

    try:
        User.create_table()
        # UserInfo.create_table()
        Post.create_table()
    except:
        pass

    app.run(debug=True, host='0.0.0.0', port=5001)
Beispiel #3
0
from web.views.CtpModelView import CtpModelView
from web.views.TickView import *
from web.views.ConfigView import ConfigView
from web.views.ServiceView import ServiceView
from web.views.RunnerView import RunnerView
from web.views.TradeView import TradeView
from redis import Redis
from flask_admin.contrib import rediscli
from common.Config import Config

# import custom view
# import web.views.RunnerView

config = Config.get()
admin.add_view(CtpModelView(Model, db.session))
admin.add_view(TickData(name='Upload Data', category='Tick'))
admin.add_view(TradeView(Trade, db.session, name='Trade'))
admin.add_view(ConfigView(name='Config', url="/admin/config"))
admin.add_view(ServiceView(Service, db.session, name='Service'))
admin.add_view(RunnerView(name='Runner', url="/admin/runner"))
admin.add_view(
    rediscli.RedisCli(
        Redis(host=config['redis']['host'], db=config['redis']['db'])))

# add tick class from config
for iid in config['iids']:
    tickModel = createTickModel(iid)
    admin.add_view(TickView(tickModel, db.session, category='Tick'))

app.run(debug=True, threaded=True)
Beispiel #4
0
            filename=op.join('img/', form.thumbgen_filename(model.path))))

    column_formatters = {'path': _list_thumbnail}

    # Alternative way to contribute field is to override it completely.
    # In this case, Flask-Admin won't attempt to merge various parameters for the field.
    form_extra_fields = {
        'path':
        form.ImageUploadField('Image',
                              base_path=img_path,
                              thumbnail_size=(100, 100, True))
    }


# Create admin interface
my_flask_admin.add_view(RoleView(Role, db.session))
my_flask_admin.add_view(UserView(User, db.session))

my_flask_admin.add_view(FoodView(Food, db.session))
my_flask_admin.add_view(CookView(Cook, db.session))
my_flask_admin.add_view(TasteView(Taste, db.session))
my_flask_admin.add_view(CuisineView(Cuisine, db.session))

my_flask_admin.add_view(FileView(File, db.session))
my_flask_admin.add_view(ImageView(Image, db.session))
my_flask_admin.add_view(PageView(Page, db.session))
my_flask_admin.add_view(rediscli.RedisCli(Redis()))

my_flask_admin.add_view(CustomizedView(name='CustomizedView'))
my_flask_admin.add_view(ComboView1(name="ComboView1", category='Combo'))
Beispiel #5
0
from flask import Flask
from redis import Redis
from flask_admin import Admin
from flask_admin.contrib import rediscli

app = Flask(__name__)

admin = Admin(app, name='microblog', template_mode='bootstrap3')

admin.add_view(rediscli.RedisCli(Redis(host='localhost',port=6379,db=0)))

app.run(port=8008)