Пример #1
0
    def _set_admin_index_view(self, index_view=None,
                              endpoint=None, url=None):
        self.index_view = (index_view or self.index_view or 
                           AdminIndexView(endpoint=endpoint, url=url))
        self.endpoint = endpoint or self.index_view.endpoint
        self.url = url or self.index_view.url

        # Add predefined index view
        # assume index view is always the first element of views.
        if len(self._views) > 0:
            self._views[0] = self.index_view
        else:
            self.add_view(self.index_view)
Пример #2
0
    from wanx.base.xmysql import MYDB
    if not MYDB.is_closed():
        MYDB.close()


babel = Babel(app)


@babel.localeselector
def get_locale():
    if request.args.get('lang'):
        session['lang'] = request.args.get('lang')
    return session.get('lang', 'zh_Hans_CN')


index_view = AdminIndexView(name=u'首页', template='home.html')

admin = Admin(app,
              name=u'玩星基地',
              index_view=index_view,
              template_mode='bootstrap3')
admin.add_view(UserAdmin(DB['users'], name=u'用户', category=u'用户管理'))
admin.add_view(GroupAdmin(DB['groups'], name=u'分组', category=u'用户管理'))
admin.add_view(UserGroupAdmin(DB['user_group'], name=u'分组用户',
                              category=u'用户管理'))

admin.add_view(GameAdmin(DB['games'], name=u'游戏', category=u'游戏管理'))
admin.add_view(WebGameAdmin(DB['web_games'], name=u'页游', category=u'游戏管理'))
admin.add_view(CategoryAdmin(DB['category'], name=u'游戏分类', category=u'游戏管理'))
admin.add_view(
    CategoryGameAdmin(DB['category_game'], name=u'游戏分类配置', category=u'游戏管理'))
Пример #3
0
            session['secure'] = None
            session['username'] = None
            session['password'] = None
            sdb.initialized = False
            return redirect(url_for('credentialsview.index'))
        return self.render('credentials.html',
                           form=form,
                           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(AciConnSearchView(name='Search'))

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

Пример #4
0
#!/usr/bin/env python3

from flask import Flask
from flask.ext.admin import Admin, AdminIndexView

from pony_admin import ModelView

from trivia.models import db
from trivia.models import Category, Question, Player, Round, Report

app = Flask(__name__)

admin = Admin(app, index_view=AdminIndexView(url='/'))


class CategoryView(ModelView):
    column_list = ['name']


admin.add_view(CategoryView(Category))


class QuestionView(ModelView):
    column_list = [
        'active', 'question', 'answer', 'times_played', 'times_solved'
    ]


admin.add_view(QuestionView(Question))

Пример #5
0
app.config['MONGODB_DB'] = 'dorabiajdb'
app.config['MONGODB_HOST'] = 'ds013579.mlab.com'
app.config['MONGODB_PORT'] = 13579
app.config['MONGODB_USERNAME'] = '******'
app.config['MONGODB_PASSWORD'] = '******'
app.config["SECRET_KEY"] = "KeepThisS3cr3t"
app.secret_key = 'A6Zr98j/3yX7R~XHH!jmN]LgX/,?-T'
app.debug = True

db = MongoEngine(app)
app.session_interface = MongoEngineSessionInterface(db)

from .api import *
from .admin import *
from .models import Province

admin = admin.Admin(app,
                    'Dorabiaj - Admin Panel',
                    template_mode='bootstrap3',
                    index_view=AdminIndexView(
                        name='Home',
                        template='admin/myhome.html',
                        url='/admin',
                    ))

admin.add_view(UserView(User))
admin.add_view(ClassifiedView(Classified))
admin.add_view(ProvinceView(Province))
admin.add_view(CategoryView(Category))
Пример #6
0
from views import *
from db import db

app = Flask(__name__)
app.config.from_object("settings")

basic_auth = BasicAuth(app)
db.init_app(app)
babel = Babel(app)

#admin
admin = Admin(app,
              u'掼蛋赛事管理系统',
              template_mode='bootstrap3',
              index_view=AdminIndexView(name=u'主页',
                                        template='admin/index.html',
                                        url='/'))
admin.add_view(
    game.views.GameAdmin(game.models.Game, name=u'赛事', endpoint='game'))
admin.add_view(
    namelist.views.NameListAdmin(namelist.models.NameList,
                                 name=u'比赛名单',
                                 endpoint='namelist'))
admin.add_view(
    game_record.views.GameRecordAdmin(game_record.models.GameRecord,
                                      name=u'比赛记录',
                                      endpoint='game-record'))
admin.add_view(BallotView(name=u'抽签', endpoint='ballot'))
admin.add_view(RankView(name=u'排名', endpoint='rank'))

if __name__ == '__main__':
Пример #7
0
#import os
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.restless import APIManager
from flask.ext.admin import Admin, AdminIndexView

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///../flask_blueprints.db'
db = SQLAlchemy(app)
manager = APIManager(app, flask_sqlalchemy_db=db)

app.secret_key = 'some_random_key'

admin = Admin(app,
              name='User Management',
              template_mode='bootstrap3',
              index_view=AdminIndexView(name='Home', url='/user-mgm'))

from app.catalog.views import catalog
app.register_blueprint(catalog)

db.create_all()