def administration_setup(app): """ Hack to use the backend administration. """ administration = Admin( name="Victims Admin", index_view=SafeAdminIndexView()) administration.init_app(app) # Application administration administration.add_view(CacheAdminView(name='Cache', endpoint='cache')) # Database management administration.add_view(AccountView( Account, name='Accounts', endpoint='accounts', category='Database') ) administration.add_view(HashView( Hash, name='Hashes', endpoint='hashes', category='Database') ) administration.add_view(SubmissionView( Submission, name='Submissions', endpoint='submissions', category='Database') ) # File Management administration.add_view(FileView( app.config['UPLOAD_FOLDER'], '/uploads/', endpoint='uploads', name='User Uploads', category='Files') ) administration.add_view(FileView( app.config['DOWNLOAD_FOLDER'], '/downloads/', endpoint='downloads', name='Charon Downloads', category='Files') ) # Add links administration.add_link(MenuLink(name='Front End', endpoint='ui.index')) administration.add_link(MenuLink( name='Logout', endpoint='auth.logout_user')) return administration
return User(user_id) if __name__ == '__main__': # Create admin interface admin = Admin(name='Example: Menu') admin.add_view(MyAdminView(name='Authenticated')) # Add home link by url admin.add_link(MenuLink(name='Back Home', url='/')) # Add login link by endpoint admin.add_link( NotAuthenticatedMenuLink(name='Login', endpoint='login_view')) # Add links with categories admin.add_link( MenuLink(name='Google', category='Links', url='http://www.google.com/')) admin.add_link( MenuLink(name='Mozilla', category='Links', url='http://mozilla.org/')) # Add logout link by endpoint admin.add_link(AuthenticatedMenuLink(name='Logout', endpoint='logout_view')) admin.init_app(app) # Start app app.run(debug=True)
from admin.index import GeneralView from admin.settings import SettingsView from admin.auth import * def rel(*x): return os.path.join(os.path.abspath(os.path.dirname(__file__)), *x) login_manager.setup_app(app) UPLOAD_FOLDER = os.path.join(rel('static'), 'uploads') ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) SETTINGS_PATH = rel('settings.cfg') admin = Admin(index_view=GeneralView()) admin.init_app(app) from admin.file_upload import * from frontend.controllers import index @app.context_processor def teardown_request(exception=None): general_meta_k = '' general_meta_d = '' menu = Menu.select() try: general_meta_k = GeneralMeta.get(id=1).meta_k general_meta_d = GeneralMeta.get(id=1).meta_d except GeneralMeta.DoesNotExist, e: print "Meta is empty, %s" % e