Skip to content

Commit

Permalink
notifications: fix email_notification_type
Browse files Browse the repository at this point in the history
* `notification_settings` is not a required field for notifications.
  To prevent `KeyError` exceptions we have to use `get`.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep and rerowep committed Nov 30, 2021
1 parent 476e3d3 commit 512ee4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rero_ils/modules/libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

0 comments on commit 512ee4b

Please sign in to comment.