Source code for invenio_records_permissions.ext
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
# Copyright (C) 2019 Northwestern University.
#
# Invenio-Records-Permissions is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see LICENSE file for
# more details.
"""Permission policies for Invenio records."""
from . import config
[docs]class InvenioRecordsPermissions(object):
"""Invenio-Records-Permissions extension."""
def __init__(self, app=None):
"""Extension initialization."""
if app:
self.init_app(app)
[docs] def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
app.extensions["invenio-records-permissions"] = self
[docs] def init_config(self, app):
"""Initialize configuration."""
# Use theme's base template if theme is installed
if "BASE_TEMPLATE" in app.config:
app.config.setdefault(
"RECORDS_PERMISSIONS_BASE_TEMPLATE",
app.config["BASE_TEMPLATE"],
)
for k in dir(config):
if k.startswith("RECORDS_PERMISSIONS_"):
app.config.setdefault(k, getattr(config, k))