diff --git a/CHANGES.rst b/CHANGES.rst index a42ec92f9a53149ce26332bff518883f23e15946..18584b287a1d605e4e9651f42e8161f0e992b2c4 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 3134866f4e9731a34ff3c885b69d6663451a8e08..41e10402a760b19e3bc0bf425ecb2d263e243738 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."""