def before_request() -> None: from openatlas.models.model import CidocClass, CidocProperty from openatlas.models.node import Node from openatlas.models.settings import Settings from openatlas.models.reference_system import ReferenceSystem if request.path.startswith('/static'): # pragma: no cover return # Avoid overhead for files if not using Apache with static alias open_connection(app.config) session['settings'] = Settings.get_settings() session['language'] = get_locale() g.cidoc_classes = CidocClass.get_all() g.properties = CidocProperty.get_all() from openatlas.models import system g.table_headers = system.get_table_headers() g.classes = system.get_system_classes() g.view_class_mapping = system.view_class_mapping g.class_view_mapping = system.get_class_view_mapping() g.nodes = Node.get_all_nodes() g.reference_systems = ReferenceSystem.get_all() g.file_stats = None # Set max file upload in MB app.config['MAX_CONTENT_LENGTH'] = \ session['settings']['file_upload_max_size'] * 1024 * 1024 if request.path.startswith('/api/'): ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) if not current_user.is_authenticated \ and not session['settings']['api_public'] \ and ip not in app.config['ALLOWED_IPS']: raise AccessDeniedError # pragma: no cover
def before_request() -> None: from openatlas.models.model import CidocClass, CidocProperty from openatlas.models.node import Node from openatlas.models.settings import Settings from openatlas.models.reference_system import ReferenceSystem if request.path.startswith('/static'): # pragma: no cover return # Only needed if not running with Apache and static alias open_connection(app.config) session['settings'] = Settings.get_settings() session['language'] = get_locale() g.cidoc_classes = CidocClass.get_all() g.properties = CidocProperty.get_all() from openatlas.models import system g.table_headers = system.get_table_headers() g.classes = system.get_system_classes() g.view_class_mapping = system.view_class_mapping g.class_view_mapping = system.get_class_view_mapping() g.nodes = Node.get_all_nodes() g.reference_systems = ReferenceSystem.get_all() # Set max file upload in MB app.config['MAX_CONTENT_LENGTH'] = session['settings'][ 'file_upload_max_size'] * 1024 * 1024
def get_type_tree() -> List[Dict[int, Dict[str, Any]]]: return [{ id_: GetTypeTree.serialize_to_json(node) } for id_, node in Node.get_all_nodes().items()]