From c596d72a8bdb06b11137dfd1b35abc5b581eac7a Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Thu, 13 Feb 2025 16:53:30 +0100
Subject: [PATCH 1/3] Allow secondary email address to be unset again

* setting an empty value in the settings form previously caused a
  validation error because the empty string is not a valid email address
---
 CHANGES.rst                         |  5 +++++
 invenio_config_tuw/users/schemas.py | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index a42ec92..18584b2 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -9,6 +9,11 @@ Changes
 =======
 
 
+Version <next>
+
+- Allow secondary email address to be removed again
+
+
 Version 2025.1.8 (released 2025-02-13)
 
 - Explicitly set calculated value for `THEME_SITEURL` in the config
diff --git a/invenio_config_tuw/users/schemas.py b/invenio_config_tuw/users/schemas.py
index 3134866..41e1040 100644
--- a/invenio_config_tuw/users/schemas.py
+++ b/invenio_config_tuw/users/schemas.py
@@ -15,7 +15,7 @@ from invenio_users_resources.services.schemas import (
     NotificationPreferences,
     UserProfileSchema,
 )
-from marshmallow import fields
+from marshmallow import fields, pre_load
 
 
 # profile
@@ -33,6 +33,14 @@ class TUWNotificationPreferencesSchema(NotificationPreferences):
 
     secondary_email = fields.Email()
 
+    @pre_load
+    def remove_empty_secondary_mail(self, data, **kwargs):
+        """Turn empty string for secondary emails into `None`."""
+        if not data.get("secondary_email"):
+            data.pop("secondary_email", None)
+
+        return data
+
 
 class TUWUserPreferencesSchema(UserPreferencesSchema):
     """User preferences schema with TU Wien extensions."""
-- 
GitLab


From 21da0e6ffb29a3a87bd04870a0e2c2c105ba1a1d Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Thu, 13 Feb 2025 16:55:35 +0100
Subject: [PATCH 2/3] Add "id" to the fake system entity

* previously, this property was missing from the fake entity which would
  trip up notification builders
---
 CHANGES.rst                                          | 1 +
 invenio_config_tuw/notifications/entity_resolvers.py | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 18584b2..8dbd145 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -12,6 +12,7 @@ Changes
 Version <next>
 
 - Allow secondary email address to be removed again
+- Add "id" to the fake entity created by `SystemEntityProxy._resolve()`
 
 
 Version 2025.1.8 (released 2025-02-13)
diff --git a/invenio_config_tuw/notifications/entity_resolvers.py b/invenio_config_tuw/notifications/entity_resolvers.py
index e6fc90a..5d2c043 100644
--- a/invenio_config_tuw/notifications/entity_resolvers.py
+++ b/invenio_config_tuw/notifications/entity_resolvers.py
@@ -27,7 +27,11 @@ class SystemEntityProxy(EntityProxy):
         Since this will mostly be used in Jinja templates, it being a dictionary
         and not an actual object is fine.
         """
-        return {"username": "system", "user_profile": {"full_name": "System"}}
+        return {
+            "id": "system",
+            "username": "system",
+            "user_profile": {"full_name": "System"},
+        }
 
     def pick_resolved_fields(self, identity, resolved_dict):
         """Select which fields to return when resolving the reference."""
-- 
GitLab


From 859f18a3e6cc3c1410079ef9a4c2c8dbe6086d29 Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Thu, 13 Feb 2025 16:56:47 +0100
Subject: [PATCH 3/3] Bump version to v2025.1.9

---
 CHANGES.rst                    | 2 +-
 invenio_config_tuw/__init__.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 8dbd145..2014348 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -9,7 +9,7 @@ Changes
 =======
 
 
-Version <next>
+Version 2025.1.9 (released 2025-02-13)
 
 - Allow secondary email address to be removed again
 - Add "id" to the fake entity created by `SystemEntityProxy._resolve()`
diff --git a/invenio_config_tuw/__init__.py b/invenio_config_tuw/__init__.py
index a902ac3..f3aeeaa 100644
--- a/invenio_config_tuw/__init__.py
+++ b/invenio_config_tuw/__init__.py
@@ -9,6 +9,6 @@
 
 from .ext import InvenioConfigTUW
 
-__version__ = "2025.1.8"
+__version__ = "2025.1.9"
 
 __all__ = ("__version__", "InvenioConfigTUW")
-- 
GitLab