mirror of
https://github.com/Cian-H/invenio-config-iform.git
synced 2025-12-22 13:11:56 +00:00
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
# Copyright (C) 2020 Mojib Wali.
|
|
#
|
|
# invenio-config-tugraz is free software; you can redistribute it and/or
|
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
# details.
|
|
|
|
"""invenio module that adds tugraz configs."""
|
|
|
|
from flask_babelex import gettext as _
|
|
|
|
from . import config
|
|
|
|
|
|
class invenioconfigtugraz(object):
|
|
"""invenio-config-tugraz extension."""
|
|
|
|
def __init__(self, app=None):
|
|
"""Extension initialization."""
|
|
# TODO: This is an example of translation string with comment. Please
|
|
# remove it.
|
|
# NOTE: This is a note to a translator.
|
|
_('A translation string')
|
|
if app:
|
|
self.init_app(app)
|
|
|
|
def init_app(self, app):
|
|
"""Flask application initialization."""
|
|
self.init_config(app)
|
|
app.extensions['invenio-config-tugraz'] = self
|
|
|
|
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(
|
|
'INVENIO_CONFIG_TUGRAZ_BASE_TEMPLATE',
|
|
app.config['BASE_TEMPLATE'],
|
|
)
|
|
for k in dir(config):
|
|
if k.startswith('INVENIO_CONFIG_TUGRAZ_'):
|
|
app.config.setdefault(k, getattr(config, k))
|