Skip to content

Commit

Permalink
notifications: fix request notification without recipient
Browse files Browse the repository at this point in the history
Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep committed Nov 18, 2021
1 parent 4c3369b commit f3d1a69
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
1 change: 0 additions & 1 deletion rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ def series_statement_format(series):
output = []
for serie in series:
output.append(series_statement_format_text(serie))
print('>>>>>>>>', output)
return output


Expand Down
5 changes: 4 additions & 1 deletion rero_ils/modules/notifications/subclasses/booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def get_language_to_use(self):
def get_recipients(self):
"""Get notification recipient email addresses."""
# Booking notification will be sent to the laon transaction library.
return [email_notification_type(self.transaction_library, self.type)]
recipient = email_notification_type(
self.transaction_library, self.type)
if recipient:
return [recipient]

@classmethod
def get_notification_context(cls, notifications=None):
Expand Down
4 changes: 3 additions & 1 deletion rero_ils/modules/notifications/subclasses/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ def get_recipients(self):
"""Get notification recipient email addresses."""
# Internal notification will be sent to the library, not to the
# patron related to the loan.
return [email_notification_type(self.library, self.type)]
recipient = email_notification_type(self.library, self.type)
if recipient:
return [recipient]
5 changes: 4 additions & 1 deletion rero_ils/modules/notifications/subclasses/transit.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def get_template_path(self):
def get_recipients(self):
"""Get notification recipient email addresses."""
# Transit notification will be sent to the loan transaction library.
return [email_notification_type(self.transaction_library, self.type)]
recipient = email_notification_type(
self.transaction_library, self.type)
if recipient:
return [recipient]

@classmethod
def get_notification_context(cls, notifications=None):
Expand Down
6 changes: 4 additions & 2 deletions tests/api/notifications/test_notifications_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,10 @@ def test_recall_notification_without_email(
for notification_type in NotificationType.ALL_NOTIFICATIONS:
process_notifications(notification_type)
# one new email for the librarian
assert mailbox[0].recipients == [email_notification_type(
lib_martigny, notification['notification_type'])]
recipient = email_notification_type(
lib_martigny, notification['notification_type'])
assert recipient
assert mailbox[0].recipients == [recipient]
# check the address block
assert patron2_martigny.dumps()['street'] in mailbox[0].body
mailbox.clear()
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/notifications/test_notifications_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def test_notification_mail(notification_late_martigny, lib_martigny, mailbox):
"""
mailbox.clear()
Dispatcher.dispatch_notifications(notification_late_martigny['pid'])
assert mailbox[0].recipients == [email_notification_type(
lib_martigny, notification_late_martigny['notification_type'])]
recipient = email_notification_type(
lib_martigny, notification_late_martigny['notification_type'])
assert recipient
assert mailbox[0].recipients == [recipient]


def test_notification_email(notification_late_sion, patron_sion, mailbox):
Expand Down

0 comments on commit f3d1a69

Please sign in to comment.