mirror of
https://github.com/Cian-H/invenio-config-iform.git
synced 2025-12-23 13:31:58 +00:00
setup: introduce ruff
* remove unused .tx. the translation is done without transifex * remove unused files * remove unused checks because ruff took over
This commit is contained in:
@@ -8,43 +8,45 @@
|
||||
|
||||
"""invenio module that adds tugraz configs."""
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from . import config
|
||||
from .custom_fields import ip_network, single_ip
|
||||
|
||||
|
||||
class InvenioConfigTugraz(object):
|
||||
class InvenioConfigTugraz:
|
||||
"""invenio-config-tugraz extension."""
|
||||
|
||||
def __init__(self, app=None):
|
||||
def __init__(self, app: Flask = None) -> None:
|
||||
"""Extension initialization."""
|
||||
if app:
|
||||
self.init_app(app)
|
||||
|
||||
def init_app(self, app):
|
||||
def init_app(self, app: Flask) -> None:
|
||||
"""Flask application initialization."""
|
||||
self.init_config(app)
|
||||
self.add_custom_fields(app)
|
||||
app.extensions["invenio-config-tugraz"] = self
|
||||
|
||||
def init_config(self, app):
|
||||
def init_config(self, app: Flask) -> None:
|
||||
"""Initialize configuration."""
|
||||
for k in dir(config):
|
||||
if k.startswith("INVENIO_CONFIG_TUGRAZ_"):
|
||||
app.config.setdefault(k, getattr(config, k))
|
||||
|
||||
def add_custom_fields(self, app):
|
||||
def add_custom_fields(self, app: Flask) -> None:
|
||||
"""Add custom fields."""
|
||||
app.config.setdefault("RDM_CUSTOM_FIELDS", [])
|
||||
app.config["RDM_CUSTOM_FIELDS"].append(ip_network)
|
||||
app.config["RDM_CUSTOM_FIELDS"].append(single_ip)
|
||||
|
||||
|
||||
def finalize_app(app):
|
||||
def finalize_app(app: Flask) -> None:
|
||||
"""Finalize app."""
|
||||
rank_blueprint_higher(app)
|
||||
|
||||
|
||||
def rank_blueprint_higher(app):
|
||||
def rank_blueprint_higher(app: Flask) -> None:
|
||||
"""Rank this module's blueprint higher than blueprint of security module.
|
||||
|
||||
Needed in order to overwrite email templates.
|
||||
|
||||
Reference in New Issue
Block a user