From 512ee4b0020ca0cc6674e87f2592524365fe0492 Mon Sep 17 00:00:00 2001 From: Peter Weber Date: Tue, 30 Nov 2021 10:11:52 +0100 Subject: [PATCH] notifications: fix email_notification_type * `notification_settings` is not a required field for notifications. To prevent `KeyError` exceptions we have to use `get`. Co-Authored-by: Peter Weber --- rero_ils/modules/libraries/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rero_ils/modules/libraries/api.py b/rero_ils/modules/libraries/api.py index e72391a861..2a033eb93f 100644 --- a/rero_ils/modules/libraries/api.py +++ b/rero_ils/modules/libraries/api.py @@ -378,6 +378,7 @@ def email_notification_type(libray, notification_type): :return: the email corresponding to the notification type. :rtype: string """ - for setting in libray['notification_settings']: + # notification_settings is not a required field. + for setting in libray.get('notification_settings', []): if setting['type'] == notification_type: return setting['email']