diff --git a/CHANGES.rst b/CHANGES.rst index c18329b124fd5046b1c9d7f737cf7c32b6779df8..445871ad2361580e1cf2d7b53249f0aa58dccacc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,13 @@ Changes ======= +Version 2024.4 (released 2024-11-26) + +- Pin `Flask-Menu`` dependency +- Add `Invenio-DAMAP` to the dependencies +- Implement TU Wien user identity generator for connection to DAMAP + + Version 2024.3 (released 2024-10-01, updated 2024-11-13) - Replace `setuptools` with `hatchling` as build tool diff --git a/invenio_config_tuw/__init__.py b/invenio_config_tuw/__init__.py index b46a6736aaac49d09318c11abe1ff1ecd8b092ba..b8ca5a3d1038c068df01d4d2a27be5d5c241927d 100644 --- a/invenio_config_tuw/__init__.py +++ b/invenio_config_tuw/__init__.py @@ -9,6 +9,6 @@ from .ext import InvenioConfigTUW -__version__ = "2024.3.2" +__version__ = "2024.4.0" __all__ = ("__version__", "InvenioConfigTUW") diff --git a/invenio_config_tuw/dmp.py b/invenio_config_tuw/dmp.py new file mode 100644 index 0000000000000000000000000000000000000000..b52c95e8ff09b1f91460757af6235d8e271d6f3c --- /dev/null +++ b/invenio_config_tuw/dmp.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2024 TU Wien. +# +# Invenio-Config-TUW is free software; you can redistribute it and/or +# modify it under the terms of the MIT License; see LICENSE file for more +# details. + +"""Utilities for connecting InvenioRDM to DAMAP, tailored to the environment of TU Wien.""" + +from flask_principal import AnonymousIdentity + + +def tuw_id_generator(identity) -> dict[str, str]: + """ + Generates user identities mapped to namespace names specific to the TUW environment. + + Parameters: + identity: The user identity. + + Returns: + dict: Namespaces with the user identifiers. + """ + identifiers = {} + if identity and not isinstance(identity, AnonymousIdentity): + u = identity.user + + if u.email.endswith("tuwien.ac.at"): + tiss_id = u.user_profile.get("tiss_id") + + if tiss_id: + identifiers["tiss_id"] = tiss_id + + return identifiers diff --git a/pyproject.toml b/pyproject.toml index f94c9bb05768b610e58fdba1f53556f6263e4c2e..b0ca2a0318a532c647b96a31ecd8112aac5dedba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,8 @@ dependencies = [ "Invenio-Search>=2.1.0,<3.0.0", "Flask>=2.0.2", "Flask-Minify>=0.47", + "Flask-Menu<2.0.0", + "Invenio-DAMAP>=0.1.1" ] [project.optional-dependencies]