def create_admin(app=None): admin = Admin(app, name="CleanBlogAdmin", index_view=MyIndexView(), base_template='admin/my_master.html') admin.add_view(UserView(User)) admin.add_view(PostView(Post))
def create_admin(app=None): admin = Admin(app, name="CargoAdmin", index_view=MyIndexView(), template_mode='bootstrap3', base_template='admins/my_master.html') admin.add_view(UserView(User, db.session)) admin.add_view(GoodsView(Goods, db.session))
def __init__(self, *args, **kwargs): """ Constructor of the class :param args: to pass on to the super class :param kwargs: to pass on to the super class :return: no return """ super(TestCase, self).__init__(*args, **kwargs) self.user_view = UserView()
def index(): return render_template('index.html') # Create admin admin = flask_admin.Admin( app, 'My Dashboard', base_template='my_master.html', template_mode='bootstrap3', ) # Add model views from views import MyModelView, UserView, CustomView, ProjectView admin.add_view(MyModelView(Role, db.session, menu_icon_type='fa', menu_icon_value='fa-server', name="Roles")) admin.add_view(UserView(User, db.session, menu_icon_type='fa', menu_icon_value='fa-users', name="Users")) admin.add_view(CustomView(name="Custom view", endpoint='custom', menu_icon_type='fa', menu_icon_value='fa-connectdevelop',)) admin.add_view(ProjectView(Project, db.session, menu_icon_type='fa', menu_icon_value='fa-gear', name="Projects")) # define a context processor for merging flask-admin's template context into the # flask-security views. @security.context_processor def security_context_processor(): return dict( admin_base_template=admin.base_template, admin_view=admin.index_view, h=admin_helpers, get_url=url_for )
init_login() admin = admin.Admin(app, 'aBay', index_view=AdminIndexView(url='/killerapp'), template_mode="bootstrap3") admin.add_view(ActiveView(ActiveItem, db_session, endpoint="active")) admin.add_view(EndedView(ActiveItem, db_session, endpoint="ended")) admin.add_view(OrderView(OrderItem, db_session, endpoint="orders")) admin.add_view(ReceiptView(SoldReceipt, db_session, endpoint="receipts")) admin.add_view(LineItemView(LineItem, db_session, endpoint="lineitem")) admin.add_view(ScraperView(db_session, endpoint="scraper")) admin.add_view(TemplateView(db_session, endpoint="template")) admin.add_view(BlackListView(db_session, endpoint="blacklist")) admin.add_view(UserView(db_session, endpoint="users")) admin.add_view(eBayAccountView(db_session, endpoint="ebayacc")) admin.add_view(NotifyEmailView(db_session, endpoint="notifyemail")) @app.template_filter() def timepast(value): c = (dt.datetime.utcnow() - value.updated_on) return "%.2dh%.2dm" % (c.seconds // 3600, (c.seconds // 60) % 60) """ Pass notifications to template """ @app.context_processor def inject_notifications():
@security.context_processor def security_context_processor(): return dict( admin_base_template=admin.base_template, admin_view=admin.index_view, h=admin_helpers, get_url=url_for ) # Add model views admin.add_view(MyModelView(Role, db.session)) admin.add_view(MyModelView(User, db.session)) # admin.add_view(FileView(File, db.session)) # admin.add_view(ImageView(Image, db.session)) admin.add_view(UserView(Markers, db.session, name='Marker')) @app.route('/admin') @login_required def admin_page(): return render_template('admin_page.html') # @app.route('/admin/Add-Parlor', methods=['GET', 'POST']) # @login_required # def add_parlor(): # return render_template('admin_add_parlor.html')