Пример #1
0
def init_admin(app):
    app.config['SECRET_KEY'] = '$\xa1<\xadB\xabNg\xa3q\x13\xf5\xfc+W'
    app.config['MONGODB_SETTINGS'] = {'DB': 'testdb'}
    from flask.ext import admin
    admin = admin.Admin(app, '后台管理')
    admin.add_view(Login(name="登录"))
    admin.add_view(RoleView(Role))
Пример #2
0
def admin_init(app):
    from flask.ext import admin
    admin = admin.Admin(app, 'Unshred', index_view=BaseAdminIndexView())
    admin.add_view(UserView(User))
    admin.add_view(TagsView(Tags))
    admin.add_view(ShredsView(Shreds))
    admin.add_view(CustomShredsView(name='Custom Shreds'))
    admin.add_view(UsersView(name='Custom Users'))
Пример #3
0
def admin_init(app):
    from flask.ext import admin
    admin = admin.Admin(app, 'Unshred', index_view=BaseAdminIndexView())
    admin.add_view(UserView(User))
    admin.add_view(TagsView(Tags))
    admin.add_view(ShredsView(Shreds))
    admin.add_view(CustomShredsView(name='Custom Shreds'))
    admin.add_view(UsersView(name='Custom Users'))
Пример #4
0
def initialize_admin_component(app):
    """ 
    Initialize the Admin Views. 
    """
    # Create admin interface
    admin = Admin(app, 'EducaWeb', index_view=MyAdminIndexView(), base_template='layout.html', template_mode='bootstrap3')
    # Add views
    admin.add_view(UserView(Usuarios))
    admin.add_view(AsignaturasView(Asignaturas))
    admin.add_view(TemasView(Temas))
    admin.add_view(PreguntasView(Preguntas))
    admin.add_view(MyView(Examenes))
Пример #5
0
def initialize_admin_component(app):
    """ 
    Initialize the Admin Views. 
    """
    # Create admin interface
    admin = Admin(app,
                  'EducaWeb',
                  index_view=MyAdminIndexView(),
                  base_template='layout.html',
                  template_mode='bootstrap3')
    # Add views
    admin.add_view(UserView(Usuarios))
    admin.add_view(AsignaturasView(Asignaturas))
    admin.add_view(TemasView(Temas))
    admin.add_view(PreguntasView(Preguntas))
    admin.add_view(MyView(Examenes))
Пример #6
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env
    
    #init the cache
    cache.init_app(app)

    #init SQLAlchemy
    db.init_app(app)
    
    # connect to the database
    mongo.init_app(app)
    
    # init admin views
    import flask.ext.admin
    admin = flask.ext.admin.Admin(app, u'用户管理系统')
    babel = Babel(app)
    @babel.localeselector
    def get_locale():
        return 'zh'
    with app.app_context():
        admin.add_view(OperatorView(mongo.db.operator, u'专员管理'))

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)

    # register our blueprints
    from controllers.main import main
    app.register_blueprint(main)

    return app
Пример #7
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    mail.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    #pagedown.init_app(app)

    #admin crap
    admin = Admin(app,
                  'Auth',
                  index_view=MyAdminIndexView(),
                  base_template='/admin/my_master.html')
    admin.add_view(AuthenticatedModelView(User, db.session))
    admin.add_view(AuthenticatedModelView(ipBlock, db.session))
    admin.add_view(AuthenticatedModelView(protectedRanges, db.session))
    path = op.join(op.dirname(__file__), 'static')
    admin.add_view(
        AuthenticatedFileAdmin(path, '/static/', name='Static Files'))

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    #disabling alexa for heroku's limited db options
    #from .services.alexa import alexa as alexa_blueprint
    #app.register_blueprint(alexa_blueprint, url_prefix="/alexa")

    from .services.mdl import mdl as mdl_blueprint
    app.register_blueprint(mdl_blueprint, url_prefix="/mdl")

    from .services.et import et as et_blueprint
    app.register_blueprint(et_blueprint, url_prefix="/et")

    from .services.phishtank import phishTank as phishTank_blueprint
    app.register_blueprint(phishTank_blueprint, url_prefix="/phishTank")

    return app
Пример #8
0
    #if helpers.validate_form_on_submit(form):
    if request.method == 'POST' and form.validate():
        user = form.get_user()
        login.login_user(user)
        return redirect(url_for('index'))

    return render_template('form.html', form=form)


@app.route('/logout/')
def logout_view():
    login.logout_user()
    return redirect(url_for('index'))


if __name__ == '__main__':
    read_env()

    allowed = User(os.environ['USERNAME'], os.environ['PASSWORD'], 1 )

    init_login()

    # Create admin
    admin = admin.Admin(app, 'Kon*Fab Admin')

    # Add views
    admin.add_view(MediaView(db.media, 'Media Outlets', endpoint='media'))
    admin.add_view(CitiesView(db.cities, 'Cities', endpoint='cities'))

    # Start app
    app.run(host='0.0.0.0', port=8888, debug=True)
Пример #9
0
            return cls.render('test.html', request=request, name="API_v1")
        def post(self, cls):
            return cls.render('test.html', request=request, name="API_v1")

    @admin.expose_plugview('/_api/2')
    class API_v2(MethodView):
        def get(self, cls):
            return cls.render('test.html', request=request, name="API_v2")
        def post(self, cls):
            return cls.render('test.html', request=request, name="API_v2")

# Create flask app
app = Flask(__name__, template_folder='templates')


# Flask views
@app.route('/')
def index():
    return redirect('/admin')


if __name__ == '__main__':
    # Create admin interface
    admin = admin.Admin()
    admin.add_view(ViewWithMethodViews())
    admin.init_app(app)

    # Start app
    app.debug = True
    app.run()
Пример #10
0
#!flask/bin/python
from app import app
from flask.ext.admin import Admin
from flask import g
from flask.ext import admin
from flask.ext.admin.contrib import sqla
from flask.ext.admin import expose
from app.models import *
import flask.ext.whooshalchemy as whooshalchemy


class FedoraModelView(sqla.ModelView):
    column_display_pk = True
    column_display_pk = True

app.config['WHOOSH_BASE'] = ''
whooshalchemy.whoosh_index(app, product)
admin = Admin(app)


admin.add_view(FedoraModelView(path, db.session))
admin.add_view(FedoraModelView(faq, db.session))
admin.add_view(FedoraModelView(product, db.session))
admin.add_view(FedoraModelView(rack, db.session))

app.run(debug=True, host='0.0.0.0')
Пример #11
0

class CategoryAdminView(sqlamodel.ModelView):
    def is_accessible(self):
        return login.current_user.is_admin()

    def __init__(self, session):
        super(CategoryAdminView, self).__init__(Category, session)


class TagAdminView(sqlamodel.ModelView):
    def is_accessible(self):
        return login.current_user.is_admin()

    def __init__(self, session):
        super(TagAdminView, self).__init__(Tag, session)


class MyAdminIndexView(admin.AdminIndexView):
    def is_accessible(self):
        return login.current_user.is_admin()


# Create admin
admin = admin.Admin(webapp, 'Admin Panel', index_view=MyAdminIndexView())
# Add views
admin.add_view(UserAdminView(db.session))
admin.add_view(ChallengeAdminView(db.session))
admin.add_view(CategoryAdminView(db.session))
admin.add_view(TagAdminView(db.session))
Пример #12
0
            as_attachment=True,
            mimetype='text/csv'
        )

    # def is_accessible(self):
    #     if login.current_user.is_authenticated():
    #         if login.current_user.is_activated:
    #             return True
    #     return False


# Create admin
admin = admin.Admin(app, 'ActivityInfo Reports', index_view=MyAdminIndexView(), base_template='my_master.html')

# Add views
admin.add_view(ReportView(Report))
admin.add_view(AdminView(User))
admin.add_view(CartoDBTableView(CartoDbTable))

# Add API
api = MongoRest(app)


class AttributeResource(Resource):
    document = Attribute


class NeNone(ops.Ne):
    def apply(self, queryset, field, value, negate=False):
        # convert nulls to python None
        if value == u'null':
Пример #13
0
    form_ajax_refs = {
        'user': (User.username, User.email),
        'tags': (Tag.name, )
    }

    def __init__(self, session):
        # Just call parent class with predefined model.
        super(PostAdmin, self).__init__(Post, session)


class TreeView(sqla.ModelView):
    inline_models = (Tree, )


if __name__ == '__main__':
    # Create admin
    admin = admin.Admin(app, 'Simple Models')

    # Add views
    admin.add_view(UserAdmin(User, db.session))
    admin.add_view(sqla.ModelView(Tag, db.session))
    admin.add_view(PostAdmin(db.session))
    admin.add_view(TreeView(Tree, db.session))

    # Create DB
    db.create_all()

    # Start app
    app.run(debug=True)
Пример #14
0
        user = User()

        form.populate_obj(user)
        user.save()

        login.login_user(user)
        return redirect(url_for('index'))

    return render_template('form.html', form=form)


@app.route('/logout/')
def logout_view():
    login.logout_user()
    return redirect(url_for('index'))


if __name__ == '__main__':
    # Initialize flask-login
    init_login()

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

    # Add view
    admin.add_view(MyModelView(User))

    # Start app
    app.debug = True
    app.run()
Пример #15
0
                           reset_form=reset_form,
                           ipaddr=session.get('ipaddr'),
                           username=session.get('username'),
                           security=session.get('secure', 'False'))


# Create admin with custom base template
homepage_view = AdminIndexView(name='Home', template='admin/index.html',
                               url='/')
admin = admin.Admin(app,
                    name='Search Tom View',
                    index_view=homepage_view,
                    base_template='layout.html')

# Add views
admin.add_view(CredentialsView(name='Credentials'))
admin.add_view(About(name='About', endpoint='about'))
admin.add_view(Feedback(name='Feedback'))
admin.add_view(AciToolkitSearchView(name='Search'))
# admin.add_view(ShowObjectView(name='Object View', endpoint='atk_object'))


@app.route("/search/<search_terms>")
def search_result_page(search_terms='1/101/1/49'):
    """
    URL to request information about a specific port
    :param search_terms:
    """
    terms = str(request.args['first'])
    print 'search terms', terms
Пример #16
0

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


# Create admin with custom base template
admin = admin.Admin(app,
                    'Example: Layout-BS3',
                    base_template='layout.html',
                    template_mode='bootstrap3')

# Add views
admin.add_view(UserAdmin(User, db.session))
admin.add_view(CustomView(Page, db.session))


def build_sample_db():
    """
    Populate a small db with some example entries.
    """

    db.drop_all()
    db.create_all()

    first_names = [
        'Harry', 'Amelia', 'Oliver', 'Jack', 'Isabella', 'Charlie', 'Sophie',
        'Mia', 'Jacob', 'Thomas', 'Emily', 'Lily', 'Ava', 'Isla', 'Alfie',
        'Olivia', 'Jessica', 'Riley', 'William', 'James', 'Geoffrey', 'Lisa',
Пример #17
0
    chicken = db.Column(db.Boolean(), default=False)
    beef = db.Column(db.Boolean(), default=False)
    last_used = db.Column(db.String(30))


class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30))


class POSAdmin(sqla.ModelView):
    column_display_pk = True


admin = Admin(app)
admin.add_view(POSAdmin(Item, db.session))
admin.add_view(POSAdmin(Product, db.session))
admin.add_view(POSAdmin(Cashier, db.session))
admin.add_view(POSAdmin(Transaction, db.session))
admin.add_view(POSAdmin(ItemAllocation, db.session))
admin.add_view(POSAdmin(Option, db.session))
admin.add_view(POSAdmin(OptionAllocation, db.session))
admin.add_view(POSAdmin(TransactionItem, db.session))
admin.add_view(POSAdmin(Sale, db.session))
admin.add_view(POSAdmin(Loyalty, db.session))
admin.add_view(POSAdmin(Category, db.session))


def least_stock(items):
    stock = items[0].stock
    for item in items:
Пример #18
0
    self.niacin = niacin
    self.ascorbic_acid = ascorbic_acid

# Admin ModelView
class IngAdmin(sqla.ModelView):
    column_display_pk = True
    
    # form_columns = ['nickname', 'description', 'status']
    # # form_overrides = dict(status=SelectField)
    # # form_args = dict(
    # #          status=dict(
    # #             choices=[('Approved', 'Approved'), ('Pending', 'Pending')]
    # #             ))

admin = Admin(app)
admin.add_view(IngAdmin(Ingredient, db.session))

@app.route('/', methods=['GET', 'POST'])
def facebook_login():
	a = Ingredient.query.all()
    	return flask.render_template('index.html',count=17, ing=a)

@app.route('/create', methods=['GET', 'POST'])
def create_database():
	db.create_all()

	a = Ingredient(food_id='1',food_and_desc='pagkaen',alternate_name='1',water='1',energy='1',protein='1',fat='1',carb='1',
		crude_fiber='1',ash='1',calcium='1',phosphorus='1',iron='1',retinol='1',bcarotene='1',vitamina='1',thiamin='1',
		riboflavin='1',niacin='1',ascorbic_acid='1')
	db.session.add(a)
	db.session.commit()
Пример #19
0
        return redirect(url_for('.index'))


def create_data():
    """ A helper function to create our tables."""
    db.create_all()
    admin_user = User(os.environ['EGM_USER'], os.environ['EGM_PASS'])
    db.session.add(admin_user)
    db.session.commit()


# Initialize flask-login
init_login()

# Create admin interface
admin = admin.Admin(name="Create or edit content:",
                    index_view=MyAdminIndexView(),
                    base_template='admin_master.html')
admin.add_view(BlogAdmin(Blog, db.session))
admin.add_view(BiographyAdmin(Biography, db.session))
admin.add_view(EventAdmin(Event, db.session))
admin.add_view(WorkAdmin(Work, db.session))
admin.add_view(UserAdmin(User, db.session))
admin.init_app(app)

if __name__ == '__main__':
    if '-c' in sys.argv:
        create_data()
    else:
        # Start app
        app.run()
Пример #20
0
    column_filters = ('civ_name', 'civ_desc')

    def __init__(self, session):
        super(CivilizationList, self).__init__(Civilization, session, category='World')


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


if __name__ == '__main__':
    admin = admin.Admin(app, 'civ-modmaker')

    admin.add_view(LeaderList(db.session))
    admin.add_view(CivilizationList(db.session))
    admin.add_view(sqlamodel.ModelView(Trait, db.session, category='Components', name='Leader Traits'))
    admin.add_view(sqlamodel.ModelView(Flaw, db.session, category='Components', name='Leader Flaws'))
    admin.add_view(ExportView(name='Export', category='Management'))

    path = op.join(op.dirname(__file__), app.config['RESOURCE_DIR'])
    try:
        os.mkdir(path)
    except OSError:
        pass

    admin.add_view(FileAdmin(path, app.config['RESOURCE_DIR'], name='Resources', category='Components'))

    db.create_all()
Пример #21
0
def make_app():
    """Creates the mediaTUM-admin Flask app.
    When more parts of mediaTUM are converted to Flask,
    we might use a "global" app to which the admin interface is added.
    """
    templates_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
    admin_app = Flask("mediaTUM admin", template_folder=templates_dir)
    admin_app.debug = True
    admin_app.config["SECRET_KEY"] = "dev"

    if DEBUG:
        admin_app.debug = True
        from werkzeug.debug import DebuggedApplication
        admin_app.wsgi_app = DebuggedApplication(admin_app.wsgi_app, True)

    admin = Admin(admin_app, name="mediaTUM", template_mode="bootstrap3",
                  index_view=IndexView(), base_template='admin_base.html')

    admin.add_view(UserView())
    admin.add_view(UserGroupView())
    admin.add_view(AuthenticatorInfoView())
    admin.add_view(OAuthUserCredentialsView())

    admin.add_view(NodeView())
    admin.add_view(FileView())
    admin.add_view(NodeAliasView())

    admin.add_view(SettingView())

    admin.add_view(AccessRuleView())
    admin.add_view(AccessRulesetView())
    admin.add_view(AccessRulesetToRuleView())

    if config.getboolean("admin.enable_rediscli", False):
        from redis import Redis
        admin.add_view(ProtectedRedisCli(Redis(db=1, port=0, unix_socket_path="/home/congkhacdung/redis/redis.sock"), name="Redis CLI"))
    
    return admin_app
Пример #22
0
class RebillView(ModelView):
	column_list = ('customer', 'pid', 'date', 'batched', 'affid', 'retrynum')
	column_filters = ['pid', 'batched', 'affid', 'retrynum', 'nmi_id']
	column_searchable_list = ('pid', 'card', 'customer')

#class AffiliateView(ModelView):
#	column_searchable_list = ('username', 'affid', 'displayname')

#class SmtpserverView(ModelView):
#	column_filters = ['storeid', 'host', 'port', 'username', 'password', 'theme']

@app.route('/refund/')
def refund():
	return '<html><body><form method="POST" action="/do_refund/">Order<input type="text"'

@app.route('/')
def index():
	return '<html><body>lol <a href="/admin/">h4x</a></body></html>'

if __name__=='__main__':
	admin= admin.Admin(app, 'datDash')

	admin.add_view(OrderView(models.Order))
	admin.add_view(CustomerView(models.Customer))
#	admin.add_view(NMIAccountView(models.NMIAccount))
	admin.add_view(RebillView(models.Rebill))
#	admin.add_view(AffiliateView(models.Affiliate))
#	admin.add_view(SmtpserverView(models.Smtpserver))

	app.run(debug=True, port=4200, host='0.0.0.0')
Пример #23
0
@app.route('/posts/')
def posts_view():
    posts = Post.query.all()
    return render_template('posts.html', posts=posts, user=login.current_user)


if __name__ == '__main__':
    # Initialize flask-login
    init_login()

    # Create admin
    admin = admin.Admin(app,
                        'Secret keeper admin panel',
                        index_view=KeeperAdminIndexView())
    admin.add_view(PostModelView(Post, db.session, url='posts'))
    admin.add_view(ModelView(Tag, db.session, url='tags'))
    admin.add_view(UserModelView(User, db.session, url='users'))

    # Create DB
    db.create_all()

    manager = APIManager(app, flask_sqlalchemy_db=db)
    manager.create_api(User, methods=['GET', 'POST', 'DELETE'])
    manager.create_api(Post, methods=['GET', 'POST', 'DELETE'])
    manager.create_api(Tag, methods=['GET', 'POST', 'DELETE'])
    # Start app
    app.debug = True
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)
Пример #24
0
    @admin.expose('/')
    def index(self):
        return self.render('anotheradmin.html')

    @admin.expose('/test/')
    def test(self):
        return self.render('test.html')


# Create flask app
app = Flask(__name__, template_folder='templates')
app.debug = True


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


# Create admin interface
admin = admin.Admin(name="Example: Simple Views")
admin.add_view(MyAdminView(name="view1", category='Test'))
admin.add_view(AnotherAdminView(name="view2", category='Test'))
admin.init_app(app)

if __name__ == '__main__':

    # Start app
    app.run()
Пример #25
0
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(30))
    last_name = db.Column(db.String(30))
    email = db.Column(db.String(60))
    password = db.Column(db.String(60))
    msisdn = db.Column(db.String(11))
    address = db.Column(db.Text)
    province = db.Column(db.String(30))
    city = db.Column(db.String(30))
    barangay = db.Column(db.String(30))

class IngAdmin(sqla.ModelView):
    column_display_pk = True
    
admin = Admin(app)
admin.add_view(IngAdmin(Item, db.session))
admin.add_view(IngAdmin(User, db.session))


def search_list(values, searchFor):
    for k in values:
        if k['id'] == searchFor:
            return k
    return None


@app.route('/', methods=['GET', 'POST'])
def index_route():
    shirts = Item.query.filter_by(category="pants").all()
    flavors = Item.query.filter_by(category="flavors").all()
    mods = Item.query.filter_by(category="mods").all()
Пример #26
0
            return cls.render('test.html', request=request, name="API_v1")

    @admin.expose_plugview('/_api/2')
    class API_v2(MethodView):
        def get(self, cls):
            return cls.render('test.html', request=request, name="API_v2")

        def post(self, cls):
            return cls.render('test.html', request=request, name="API_v2")


# Create flask app
app = Flask(__name__, template_folder='templates')


# Flask views
@app.route('/')
def index():
    return redirect('/admin')


if __name__ == '__main__':
    # Create admin interface
    admin = admin.Admin()
    admin.add_view(ViewWithMethodViews())
    admin.init_app(app)

    # Start app
    app.debug = True
    app.run()
Пример #27
0
            flash('Rollback successfully processed', 'success')
            return redirect(url_for('rollbackview.index'))
        return self.render('rollback.html', form=form, versions=[])


# Create admin with custom base template
homepage_view = AdminIndexView(name='Home',
                               template='admin/index.html',
                               url='/')
admin = admin.Admin(app,
                    name='Snapback',
                    index_view=homepage_view,
                    base_template='layout.html')

# Add views
admin.add_view(CredentialsView(name='Credentials'))
admin.add_view(
    ScheduleSnapshot(name='Schedule Snapshot', endpoint='schedulesnapshot'))
admin.add_view(SnapshotsAdmin(Snapshots, db.session,
                              endpoint="snapshotsadmin"))
admin.add_view(RollbackView(name='Version Rollback'))
admin.add_view(StackedDiffs(name='Version Diffs'))
admin.add_view(About(name='About'))
admin.add_view(FileView(name='View'))
admin.add_view(DiffView(name='View Diffs'))
admin.add_view(Feedback(name='Feedback'))


def build_db():
    """
    Populate the db with the existing snapshot images.
Пример #28
0
class CarAdmin(sqla.ModelView):
    column_display_pk = True
    form_columns = ['id', 'title', 'E_mail', 'Name', 'Surname', 'block']
    column_searchable_list = ('title', )


class CarAdmin1(sqla.ModelView):
    @expose('/')
    def index(self):
        return self.render('ggga.html')


admin = admin.Admin(app, name='Admin')

admin.add_view(CarAdmin(Users, db.session))
admin.add_view(CarAdmin1(GoHome, db.session))


@app.route('/ShowRes_pass')
def ShowRes_pass():
    return render_template('ggg1.html')


@app.route('/Res_pass', methods=['POST', 'GET'])
def Res_pass():
    try:
        global log
        log = request.values['projectFilepath9']
        conn = sqlite3.connect("mydatabaseq1.db")
        cursor1 = conn.cursor()
Пример #29
0
from email.mime.text import MIMEText as text
import os
import db_conn
from db_conn import db, app
from models import Household, ParentChild, Citizen, HouseholdImage, AdminUser

APP_SECRET = '01c5d1f8d3bfa9966786065c5a2d829d7e84cf26fbfb4a47c91552cb7c091608'
now = datetime.datetime.now()


class IngAdmin(sqla.ModelView):
    column_display_pk = True


admin = Admin(app, name='mobilization')
admin.add_view(IngAdmin(Household, db.session))
admin.add_view(IngAdmin(Citizen, db.session))
admin.add_view(IngAdmin(ParentChild, db.session))


def nocache(view):
    @wraps(view)
    def no_cache(*args, **kwargs):
        response = make_response(view(*args, **kwargs))
        response.headers['Last-Modified'] = datetime.datetime.now()
        response.headers[
            'Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '-1'
        return response
Пример #30
0
        return self._feed_user_choices(form)

    def edit_form(self, obj):
        form = super(TweetView, self).edit_form(obj)
        return self._feed_user_choices(form)

    # Correct user_id reference before saving
    def on_model_change(self, form, model):
        user_id = model.get('user_id')
        model['user_id'] = ObjectId(user_id)

        return model


# 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, name='Example: PyMongo')

    # Add views
    admin.add_view(UserView(db.user, 'User'))
    admin.add_view(TweetView(db.tweet, 'Tweets'))

    # Start app
    app.run(debug=True)
Пример #31
0
        """

        :param args:
        :param kwargs:
        :return:
        """
        return redirect(url_for('fileview.index'))

# Create admin with custom base template
homepage_view = AdminIndexView(name='Home', template='admin/index.html',
                               url='/')
admin = admin.Admin(app,
                    name='ReportView',
                    index_view=homepage_view,
                    base_template='layout.html')

# Add views
admin.add_view(CredentialsView(name='Credentials'))
admin.add_view(About(name='About'))
admin.add_view(Feedback(name='Feedback'))
admin.add_view(SelectSwitchView(name='Switch Reports'))
admin.add_view(SelectTenantView(name='Tenant Reports'))

if __name__ == '__main__':
    description = 'ACI Report Viewer Tool.'
    creds = Credentials('server', description)
    args = creds.get()

    # Start app
    app.run(debug=True, host=args.ip, port=int(args.port))
Пример #32
0
from flask import Flask

from redis import Redis

from flask.ext import admin
from flask.ext.admin.contrib import rediscli

# Create flask app
app = Flask(__name__)


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


if __name__ == '__main__':
    # Create admin interface
    admin = admin.Admin(app, name="Example: Redis")
    admin.add_view(rediscli.RedisCli(Redis()))

    # Start app
    app.run(debug=True)
Пример #33
0
    """Logs the user out."""
    flash('You were logged out')
    return redirect(url_for('index'))

@app.route('/posts/')
def posts_view():
    posts = Post.query.all()
    return render_template('posts.html', posts=posts, user=login.current_user)

if __name__ == '__main__':
    # Initialize flask-login
    init_login()

    # Create admin
    admin = admin.Admin(app, 'Secret keeper admin panel', index_view=KeeperAdminIndexView())
    admin.add_view(PostModelView(Post, db.session, url='posts'))
    admin.add_view(ModelView(Tag, db.session, url='tags'))
    admin.add_view(UserModelView(User, db.session, url='users'))

    # Create DB
    db.create_all()

    manager = APIManager(app, flask_sqlalchemy_db=db)
    manager.create_api(User, methods=['GET', 'POST', 'DELETE'])
    manager.create_api(Post, methods=['GET', 'POST', 'DELETE'])
    manager.create_api(Tag, methods=['GET', 'POST', 'DELETE'])
    # Start app
    app.debug = True
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)
Пример #34
0
    def __init__(self, session, **kwargs):
        # You can pass name and other parameters if you want to
        super(SkillView, self).__init__(SkillPair, session, **kwargs)


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


# Create admin
admin = admin.Admin(app, 'SkillCluster')

# Add views
admin.add_view(SkillView(db.session))
#admin.add_view(PercentagesView(db.session))


def build_db():

    db.drop_all()
    db.create_all()

    skillKeywords = [
        "AJAX", "AMQP", "Android", "Angular", "Ant", "ApacheMQ", "Artifactory",
        "ASP.NET", "Backbone", "Bootstrap", "C++", "C#", "Cassandra", "Chef",
        "CSS", "Crystal Reports", "Delphi", "DevOps", "Django", "Eclipse",
        "Ember", "Entity Framework", "Flash", "Flask", "FoxPro", "IIS", "GIS",
        "Git", "Hadoop", "Handlebars", "Hibernate", "HTML", "HTML5", "J2EE",
        "Java", "Javascript", "JBOSS", "JCE", "JDBC", "Jenkins", "JMS", "JNDI",
Пример #35
0
import schedule
from werkzeug.utils import secure_filename
from tasks import send_notification
import db_conn
from db_conn import db, app
from models import *

IPP_URL = 'https://devapi.globelabs.com.ph/smsmessaging/v1/outbound/%s/requests'
UPLOAD_FOLDER = 'static/receipts'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

class BubbleAdmin(sqla.ModelView):
    column_display_pk = True

admin = Admin(app, name='bubble')
admin.add_view(BubbleAdmin(Client, db.session))
admin.add_view(BubbleAdmin(AdminUser, db.session))
admin.add_view(BubbleAdmin(Transaction, db.session))
admin.add_view(BubbleAdmin(TransactionItem, db.session))
admin.add_view(BubbleAdmin(Service, db.session))
admin.add_view(BubbleAdmin(Bill, db.session))
# admin.add_view(BubbleAdmin(Service, db.session))

def nocache(view):
    @wraps(view)
    def no_cache(*args, **kwargs):
        response = make_response(view(*args, **kwargs))
        response.headers['Last-Modified'] = datetime.datetime.now()
        response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '-1'
Пример #36
0
import webbrowser

from flask.ext import admin

from app import app, db, path, logger, files
from models import Points, Coms, Unit
from views import PointsView, ComsView, UnitView, HomeView

if __name__ == '__main__':
    # Create directory
    try:
        os.mkdir(path)
    except OSError:
        pass
    
    # Create admin interface
    admin = admin.Admin(app, 'Flash Trends', index_view=HomeView(name='Home'))
    
    admin.add_view(UnitView(Unit, db.session, name='Units', category='Setup'))
    admin.add_view(ComsView(Coms, db.session, name='Serial coms', category='Setup'))
    admin.add_view(PointsView(Points, db.session, category='Setup'))
    
    admin.add_view(files)

    # Open web browser
    #webbrowser.open('http://127.0.0.1:8080/admin/')

    # Start app
    app.run(debug=True, host='0.0.0.0', port=8080)

Пример #37
0
        return self._feed_user_choices(form)

    def edit_form(self, obj):
        form = super(TweetView, self).edit_form(obj)
        return self._feed_user_choices(form)

    # Correct user_id reference before saving
    def on_model_change(self, form, model):
        user_id = model.get('user_id')
        model['user_id'] = ObjectId(user_id)

        return model


# 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, name='Example: PyMongo')

    # Add views
    admin.add_view(UserView(db.user, 'User'))
    admin.add_view(TweetView(db.tweet, 'Tweets'))

    # Start app
    app.run(debug=True)
Пример #38
0
        return self.url

class UrlView(ModelView):
    #column_select_related_list = ('primary_term', 'secondary_term', 'ratio')
    column_searchable_list = ("url","domain")
    column_filters = ('url','domain')

    def __init__(self, session, **kwargs):
        # You can pass name and other parameters if you want to
        super(UrlView, self).__init__(CrawledUrl, session, **kwargs)

# Create admin
admin = admin.Admin(app, 'FocusCrawlerVIz')

# Add views
admin.add_view(UrlView(db.session))

def build_db():
    db.drop_all()
    db.create_all()

    csvfile = "/Users/cdoig/memexcrawler/viz/app/data_preprocessed/crawledpages.csv"
    with open(csvfile, 'rb') as f:
        reader = unicodecsv.reader(f, encoding='utf-8', delimiter='\t')
        for row in reader:
            crawledurl = CrawledUrl()
            crawledurl.url = row[0]
            #crawledurl.url = '<a href="%s">%s</a><div class="box"><iframe src="%s" width = "500px" height = "500px"></iframe></div>' % (url, url, url)
            crawledurl.domain = row[1]
            crawledurl.datetime = row[3]
            db.session.add(crawledurl)
Пример #39
0
    list_template = 'list.html'
    create_template = 'create.html'
    edit_template = 'edit.html'


class UserAdmin(CustomView):
    column_searchable_list = ('name',)
    column_filters = ('name', 'email')


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


if __name__ == '__main__':
    # Create admin with custom base template
    admin = admin.Admin(app, base_template='layout.html')

    # Add views
    admin.add_view(UserAdmin(User, db.session))
    admin.add_view(CustomView(Page, db.session))

    # Create DB
    db.create_all()

    # Start app
    app.debug = True
    app.run('0.0.0.0', 8001)
Пример #40
0
    id = db.Column(db.Integer, primary_key=True)
    kiosk_id = db.Column(db.String(32))
    date = db.Column(db.String(20))
    school_id = db.Column(db.String(32))
    school_name = db.Column(db.String(50))
    student_entry_log_count = db.Column(db.Integer())
    student_exit_log_count = db.Column(db.Integer())
    faculty_entry_log_count = db.Column(db.Integer())
    faculty_exit_log_count = db.Column(db.Integer())
    unsynced_log_count = db.Column(db.Integer())
    unsent_notification_count = db.Column(db.Integer())

class IngAdmin(sqla.ModelView):
    column_display_pk = True
admin = Admin(app, name='raven')
admin.add_view(IngAdmin(Report, db.session))
admin.add_view(IngAdmin(School, db.session))


@app.route('/', methods=['POST','GET'])
def render_index():
    reports = Report.query.all()
    return flask.render_template('index.html',reports=reports)


@app.route('/report/status/new', methods=['POST'])
def save_status_report():
    data = flask.request.form.to_dict()
    school = School.query.filter_by(api_key=data['api_key']).first()

    if school == None:
Пример #41
0
# meh, add a route for media, files, etc and something like
# http://www.boxcontrol.net/simple-stream-your-media-with-flask-python-web-framework-tutorial.html


if __name__ == '__main__':
    # Initialize flask-login
    init_login()

    # Create admin
    admin = admin.Admin(app, 
                        'Kegger', 
                        base_template='layout.html', 
                        template_mode='bootstrap3',
                        index_view=AuthAdminIndexView()
                        )

    # Add views
    admin.add_view(UserView(User, name="Users"))
    admin.add_view(ModelView(Artist))
    admin.add_view(ModelView(Media))
    admin.add_view(ModelView(File))
    admin.add_view(rediscli.RedisCli(Redis()))

    os.makedirs(settings.MEDIA_FOLDER, exist_ok=True)

    # media manager
    admin.add_view(fileadmin.FileAdmin(settings.MEDIA_FOLDER + '/', name='Local Media'))

    # Start app
    app.run(debug=True)
Пример #42
0
from blueprints.wiki.views import wiki
from blueprints.projects.views import projects
from blueprints.downloads.views import downloads
from blueprints.downloads.models import Download
neobug.register_blueprint(wiki, url_prefix='/wiki')
neobug.register_blueprint(projects, url_prefix='/projects')
neobug.register_blueprint(downloads, url_prefix='/downloads')


def init_login():
    login_manager = login.LoginManager()
    login_manager.init_app(neobug)

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects.where("this.username=='" + user_id + "'")[0]


init_login()

admin = admin.Admin(neobug, 'neobug', index_view=MyAdminIndexView())
admin.add_view(UserView(User))
admin.add_view(ProjectView(Project))
admin.add_view(IssueView(Issue))
admin.add_view(OverviewView(Overview))
admin.add_view(DownloadView(Download))

if __name__ == "__main__":
    neobug.run()
Пример #43
0
                           ipaddr=session.get('ipaddr'),
                           username=session.get('username'),
                           security=session.get('secure', 'False'))


# Create admin with custom base template
homepage_view = AdminIndexView(name='Home',
                               template='admin/index.html',
                               url='/')
admin = admin.Admin(app,
                    name='Search Tom View',
                    index_view=homepage_view,
                    base_template='layout.html')

# Add views
admin.add_view(CredentialsView(name='Credentials'))
admin.add_view(About(name='About', endpoint='about'))
admin.add_view(Feedback(name='Feedback'))
admin.add_view(AciConnSearchView(name='Search'))

# admin.add_view(ShowObjectView(name='Object View', endpoint='atk_object'))


def build_flow_spec(terms):
    flow_spec = FlowSpec()
    protocol_filter = ProtocolFilter()
    flow_spec.protocol_filter = [protocol_filter]

    fields = input_parser(terms)
    num_filters = 1
    if 'dport' in fields or 'sport' in fields:
Пример #44
0

# Create flask app
app = Flask(__name__, template_folder='templates', static_folder='files')

# Create dummy secrey key so we can use flash
app.config['SECRET_KEY'] = '123456790'


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


if __name__ == '__main__':
    # Create directory
    path = op.join(op.dirname(__file__), 'files')
    try:
        os.mkdir(path)
    except OSError:
        pass

    # Create admin interface
    admin = admin.Admin(app)
    admin.add_view(fileadmin.FileAdmin(path, '/files/', name='Files'))

    # Start app
    app.debug = True
    app.run()
Пример #45
0
    @admin.expose('/')
    def index(self):
        return self.render('anotheradmin.html')

    @admin.expose('/test/')
    def test(self):
        return self.render('test.html')


# Create flask app
app = Flask(__name__, template_folder='templates')
app.debug = True


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


# Create admin interface
admin = admin.Admin()
admin.add_view(MyAdminView(category='Test'))
admin.add_view(AnotherAdminView(category='Test'))
admin.init_app(app)

if __name__ == '__main__':

    # Start app
    app.run()
Пример #46
0
@app.route('/')
def index():
    return render_template('index.html')


# Initialize flask-login
init_login()

# Create admin
admin = admin.Admin(app,
                    'Example: Auth',
                    index_view=MyAdminIndexView(),
                    base_template='my_master.html')

# Add view
admin.add_view(MyModelView(User, db.session))


def build_sample_db():
    """
    Populate a small db with some example entries.
    """

    import string
    import random

    db.drop_all()
    db.create_all()
    # passwords are hashed, to use plaintext passwords instead:
    # test_user = User(login="******", password="******")
    test_user = User(login="******", password=generate_password_hash("test"))
Пример #47
0
        db.session.add(user)
        db.session.commit()

        login.login_user(user)
        return redirect(url_for('index'))

    return render_template('form.html', form=form)


@app.route('/logout/')
def logout_view():
    login.logout_user()
    return redirect(url_for('index'))

if __name__ == '__main__':
    # Initialize flask-login
    init_login()

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

    # Add view
    admin.add_view(MyModelView(User, db.session))

    # Create DB
    db.create_all()

    # Start app
    app.run(debug=True)
Пример #48
0
    # def is_accessible(self):
    #     if login.current_user.is_authenticated():
    #         if login.current_user.is_activated:
    #             return True
    #     return False


# Create admin
admin = admin.Admin(app,
                    'ActivityInfo Reports',
                    index_view=MyAdminIndexView(),
                    base_template='my_master.html')

# Add views
admin.add_view(ReportView(Report))
admin.add_view(AdminView(User))
admin.add_view(CartoDBTableView(CartoDbTable))

# Add API
api = MongoRest(app)


class AttributeResource(Resource):
    document = Attribute


class NeNone(ops.Ne):
    def apply(self, queryset, field, value, negate=False):
        # convert nulls to python None
        if value == u'null':
Пример #49
0
    text = db.Column(db.Text, nullable=False)
    date = db.Column(db.DateTime)

    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.Admin(app, 'Simple Models')

    admin.locale_selector(get_locale)

    # Add views
    admin.add_view(sqlamodel.ModelView(User, db.session))
    admin.add_view(sqlamodel.ModelView(Post, db.session))

    # Create DB
    db.create_all()

    # Start app
    app.run(debug=True)
                        'name': {
                            'style': 'color: red'
                        }
                    }
                }
            }
        }
    }

# 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, 'Simple Models')

    # Add views
    admin.add_view(UserView(User))
    admin.add_view(TodoView(Todo))
    admin.add_view(ModelView(Tag))
    admin.add_view(PostView(Post))
    admin.add_view(ModelView(File))
    admin.add_view(ModelView(Image))

    # Start app
    app.run(debug=True)

Пример #51
0

@app.route('/login', methods=('GET', 'POST'))
def login_view():
    form = LoginForm(request.form)
    if helpers.validate_form_on_submit(form):
        user = form.get_user()
        login.login_user(user,remember=form.remember_me)        
        return redirect(request.args.get("next") or url_for("index"))

    return render_template('login.html', 
        title="Login",user=login.current_user,
        form=form)

@app.route('/logout/')
def logout_view():
    login.logout_user()
    return redirect(url_for('index'))

@login_manager.user_loader
def load_user(userid):
    return User.get_by_id(userid)


#init_login()

admin = admin.Admin(app, 'Auth', index_view=AdminIndexView())
admin.add_view(UserModelView(User, db.session))
admin.add_view(UserModelView(Task, db.session))
# setup()
Пример #52
0

from blueprints.wiki.views import wiki
from blueprints.projects.views import projects
from blueprints.downloads.views import downloads
from blueprints.downloads.models import Download
neobug.register_blueprint(wiki, url_prefix='/wiki')
neobug.register_blueprint(projects, url_prefix='/projects')
neobug.register_blueprint(downloads, url_prefix='/downloads')


def init_login():
    login_manager = login.LoginManager()
    login_manager.init_app(neobug)

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects.where("this.username=='" + user_id + "'")[0]

init_login()

admin = admin.Admin(neobug, 'neobug', index_view=MyAdminIndexView())
admin.add_view(UserView(User))
admin.add_view(ProjectView(Project))
admin.add_view(IssueView(Issue))
admin.add_view(OverviewView(Overview))
admin.add_view(DownloadView(Download))

if __name__ == "__main__":
    neobug.run()
Пример #53
0

class FileAdmin(sqla.ModelView):
    can_create = False
    can_delete = False
    form_columns = ['original_name', 'server_name', 'file_hash', 'chunk_size', 'chunk_number']
    column_filters = ('original_name', 'server_name', 'file_hash', 'chunk_size', 'chunk_number')

    def is_accessible(self):
        return login.current_user.is_authenticated()


class FileServerAdmin(sqla.ModelView):
    form_columns = ['ip', 'port', 'status', 'last_online']
    column_filters = ('ip', 'port', 'status', 'last_online')

    def is_accessible(self):
        return login.current_user.is_authenticated()


init_login()
tables_category = unicode('Таблицы', 'utf-8')
admin = admin.Admin(app, 'Cloud storage', index_view=CustomAdminIndexView(), base_template='my_master.html')
admin.add_view(AccountTypeAdmin(dbTables.AccountType, db_connection.session, category=tables_category, name='Account type'))
admin.add_view(CatalogAdmin(dbTables.Catalog, db_connection.session, category=tables_category, name='Catalog'))
admin.add_view(GroupAdmin(dbTables.Group, db_connection.session, category=tables_category, name='Groups'))
admin.add_view(FileAdmin(dbTables.File, db_connection.session, category=tables_category, name='File'))
admin.add_view(FileServerAdmin(dbTables.FileServer, db_connection.session, category=tables_category, name='File server'))
admin.add_view(FileSpaceAdmin(dbTables.FileSpace, db_connection.session, category=tables_category, name='File space'))
admin.add_view(UsersAdmin(dbTables.Users, db_connection.session, category=tables_category, name='Users'))
Пример #54
0
    # Pass arguments to WTForms. In this case, change label for text field to
    # be 'Big Text' and add required() validator.
    form_args = dict(
                    text=dict(label='Big Text', validators=[validators.required()])
                )

    def __init__(self, session):
        # Just call parent class with predefined model.
        super(PostAdmin, self).__init__(Post, session)


class TreeView(sqla.ModelView):
    inline_models = (Tree,)


if __name__ == '__main__':
    # Create admin
    admin = admin.Admin(app, 'Simple Models')

    # Add views
    admin.add_view(UserAdmin(User, db.session))
    admin.add_view(sqla.ModelView(Tag, db.session))
    admin.add_view(PostAdmin(db.session))
    admin.add_view(TreeView(Tree, db.session))

    # Create DB
    db.create_all()

    # Start app
    app.run(debug=True)
Пример #55
0
  if (msg_reverse == 1) :
    msg_list_rvs = msg_list[p_msg_s:p_msg_e]
    msg_list_rvs.reverse()
    msg = { 'command' : 'new_message', 'msg_s' : msg_s, 'msg_e' : msg_e, 
      'msg_reverse' : msg_reverse, 
      'data' : msg_list_rvs }
  else :
    msg = { 'command' : 'new_message', 'msg_s' : msg_s, 'msg_e' : msg_e, 
      'data' : msg_list[p_msg_s:p_msg_e] }

  log.warning('** arraged msg start = %d - msg end = %d' % (msg_s, msg_e))
  log.warning('last msgs count = %d', last_msg_index) 
  log.warning(msg) 

  return jsonify(msg)

if __name__ == '__main__':
  # Initialize flask-login
  init_login()

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

  # Add view
  admin.add_view(MyModelView(User))
  #admin.add_view(MapView(name='MapView'))

  # Start app
  app.run(debug=True, host='0.0.0.0')
Пример #56
0
                                                  ('test2', 'Test 2'))))
    form_args = dict(text=dict(label='Big Text', validators=[]))

    def __init__(self, session):
        super(UserDetailAdmin, self).__init__(UserDetail, session)

    def is_accessible(self):
        if current_user.get_role() == '0':
            return current_user.is_authenticated()


# Create admin
admin = admin.Admin(app, 'FlaskCamel Admin')

# Add views to admin
admin.add_view(UsersAdmin(db.session))
admin.add_view(UserDetailAdmin(db.session))

########NEW FILE########
__FILENAME__ = views
from datetime import datetime, date

from itsdangerous import URLSafeSerializer

from flask import render_template, url_for, redirect, flash, request, session
from flask.ext.login import (LoginManager, current_user, login_required,
                             login_user, logout_user, AnonymousUser)
from flask.ext.mail import Mail, Message
from flaskext.bcrypt import Bcrypt
from flask_debugtoolbar import DebugToolbarExtension
from flask.ext.oauth import OAuth
Пример #57
0
    # Column filters
    column_filters = ('title',
                      'date',
                      User.username)


@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, 'Peewee Models')

    admin.add_view(UserAdmin(User))
    admin.add_view(PostAdmin(Post))

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

    app.run(debug=True)
Пример #58
0
    date = db.Column(db.DateTime)

    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.Admin(app, 'Simple Models')

    #admin.locale_selector(get_locale)

    # Add views
    admin.add_view(sqla.ModelView(User, db.session))
    admin.add_view(sqla.ModelView(Post, db.session))

    # Create DB
    db.create_all()

    # Start app
    app.run(debug=True)