コード例 #1
0
ファイル: __init__.py プロジェクト: craws/OpenAtlas
def before_request() -> None:
    from openatlas.models.openatlas_class import (OpenatlasClass,
                                                  view_class_mapping)
    from openatlas.models.cidoc_property import CidocProperty
    from openatlas.models.cidoc_class import CidocClass
    from openatlas.models.type import Type
    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)
    g.settings = Settings.get_settings()
    session['language'] = get_locale()
    g.cidoc_classes = CidocClass.get_all()
    g.properties = CidocProperty.get_all()
    g.classes = OpenatlasClass.get_all()
    g.types = Type.get_all()
    g.reference_systems = ReferenceSystem.get_all()
    g.view_class_mapping = view_class_mapping
    g.class_view_mapping = OpenatlasClass.get_class_view_mapping()
    g.table_headers = OpenatlasClass.get_table_headers()
    g.file_stats = get_file_stats()

    # Set max file upload in MB
    app.config['MAX_CONTENT_LENGTH'] = \
        g.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 g.settings['api_public'] \
                and ip not in app.config['ALLOWED_IPS']:
            raise AccessDeniedError  # pragma: no cover
コード例 #2
0
 def get_type_tree() -> dict[int, Any]:
     return {
         id_: GetTypeTree.serialize_to_json(type_)
         for id_, type_ in Type.get_all().items()
     }
コード例 #3
0
ファイル: type_tree.py プロジェクト: craws/OpenAtlas
 def get_type_tree() -> list[dict[int, dict[str, Any]]]:
     return [{
         id_: GetTypeTree.serialize_to_json(node)
     } for id_, node in Type.get_all().items()]