def app(): """Create application for the tests.""" _app = create_app("tests.settings") _app.logger.setLevel(logging.CRITICAL) ctx = _app.test_request_context() ctx.push() yield _app ctx.pop()
def app(): """Create application for the tests.""" _app = create_app("tests.settings") _app.logger.setLevel(logging.CRITICAL) ctx = _app.test_request_context() ctx.push() @_app.context_processor def utility_processor(): def navigation(role, view=None): if role in ["a", "a/i"] and not view: return ( ("public.home", "Home"), ("dashboard.admin", "Admin Dashboard"), ("dashboard.scenarios", "Scenarios"), ("public.about", "About"), ) elif (role == "i" and not view) or ( role in ["a", "a/i"] and view == "instructorView" ): return ( ("public.home", "Home"), ("dashboard.instructor", "Instructor Dashboard"), ("dashboard.scenarios", "Scenarios"), ("public.about", "About"), ) elif (role is not None) or ( role in ["a", "a/i", "i"] and view == "studentView" ): return ( ("public.home", "Home"), ("dashboard.student", "Dashboard"), ("public.about", "About"), ) else: return (("public.home", "Home"), ("public.about", "About")) return dict(navigation=navigation) _app.jinja_env.globals.update(Aid=Aid) _app.jinja_env.globals.update(Iid=Iid) _app.jinja_env.globals.update(get_role=get_role) yield _app ctx.pop()
def __call__(self, *args, **kwargs): from edurange_refactored.app import create_app with create_app().app_context(): return super(ContextTask, self).__call__(*args, **kwargs)
"""Create an application instance.""" from edurange_refactored.app import create_app from edurange_refactored.user.models import User, StudentGroups from edurange_refactored.extensions import db from edurange_refactored.utils import generateNavElements import os from datetime import datetime from flask import session from flask_login import current_user from edurange_refactored.app import create_app from edurange_refactored.extensions import db from edurange_refactored.user.models import StudentGroups, User app = create_app() app.app_context().push() db.create_all() @app.context_processor def utility_processor(): def navigation(role, view=session.get('viewMode')): return generateNavElements(role, view) return dict(navigation=navigation) def create_admin(): username = os.environ["FLASK_USERNAME"] email = os.environ["EMAIL"]