-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notification: create 'at_desk' notification
When an item arrives 'at_desk' a notification was already sent to the patron to alert it that the item is now available (availability notification). A sibling notification is now sent to the transaction library (at_desk notification) ; mainly for printing usage. Closes #2695. Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
- Loading branch information
Showing
15 changed files
with
259 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,7 @@ | |
"due_soon", | ||
"overdue", | ||
"availability", | ||
"at_desk", | ||
"recall", | ||
"transit_notice", | ||
"request", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# RERO ILS | ||
# Copyright (C) 2022 RERO | ||
# Copyright (C) 2022 UCLouvain | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""API for manipulating "at_desk" circulation notifications.""" | ||
|
||
from __future__ import absolute_import, print_function | ||
|
||
from rero_ils.filter import format_date_filter | ||
from rero_ils.modules.documents.dumpers import DocumentGenericDumper | ||
from rero_ils.utils import language_iso639_2to1 | ||
|
||
from .internal import InternalCirculationNotification | ||
from ...items.dumpers import ItemNotificationDumper | ||
from ...locations.api import Location | ||
from ...patrons.api import Patron | ||
from ...patrons.dumpers import PatronNotificationDumper | ||
|
||
|
||
class AtDeskCirculationNotification(InternalCirculationNotification): | ||
"""At_desk circulation notifications class. | ||
An "at_desk" notification is a message send to a library to notify that an | ||
item arrives AT_DESK. It's just the same than AVAILABILITY notification | ||
except that the notification isn't send to the patron but to the | ||
transaction library. | ||
Administrator can define a delay between notification creation and | ||
notification dispatching. | ||
As one of the purpose of this notification is to be printed, it should | ||
never be aggregated. | ||
""" | ||
|
||
def get_template_path(self): | ||
"""Get the template to use to render the notification.""" | ||
return f'email/at_desk/{self.get_language_to_use()}.txt' | ||
|
||
def get_recipients_to(self): | ||
"""Get notification recipient email addresses.""" | ||
# At desk notification will be sent to the loan transaction library. | ||
recipient = self.transaction_library.get_email(self.type) | ||
if recipient: | ||
return [recipient] | ||
|
||
@classmethod | ||
def get_notification_context(cls, notifications=None): | ||
"""Get the context to render the notification template.""" | ||
context = {'loans': []} | ||
notifications = notifications or [] | ||
|
||
doc_dumper = DocumentGenericDumper() | ||
item_dumper = ItemNotificationDumper() | ||
patron_dumper = PatronNotificationDumper() | ||
for notification in notifications: | ||
loan = notification.loan | ||
creation_date = format_date_filter( | ||
notification.get('creation_date'), date_format='medium', | ||
locale=language_iso639_2to1(notification.get_language_to_use()) | ||
) | ||
request_expire_date = format_date_filter( | ||
loan.get('request_expire_date'), date_format='medium', | ||
locale=language_iso639_2to1(notification.get_language_to_use()) | ||
) | ||
# merge doc and item metadata preserving document key | ||
item_data = notification.item.dumps(dumper=item_dumper) | ||
doc_data = notification.document.dumps(dumper=doc_dumper) | ||
doc_data = {**item_data, **doc_data} | ||
# pickup location name --> !! pickup is on notif.request_loan, not | ||
# on notif.loan | ||
request_loan = notification.request_loan | ||
pickup_location = Location.get_record_by_pid( | ||
request_loan.get('pickup_location_pid')) | ||
if not pickup_location: | ||
pickup_location = Location.get_record_by_pid( | ||
request_loan.get('transaction_location_pid')) | ||
# request_patron | ||
request_patron = Patron.get_record_by_pid( | ||
request_loan.get('patron_pid')) | ||
|
||
loan_context = { | ||
'creation_date': creation_date, | ||
'document': doc_data, | ||
'pickup_name': pickup_location.get( | ||
'pickup_name', pickup_location.get('name')), | ||
'request_expire_date': request_expire_date, | ||
'patron': request_patron.dumps(dumper=patron_dumper) | ||
} | ||
context['loans'].append(loan_context) | ||
|
||
return context |
17 changes: 17 additions & 0 deletions
17
rero_ils/modules/notifications/templates/email/at_desk/eng.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Item at desk | ||
|
||
{% for loan in loans -%} | ||
Date: {{ loan.creation_date }} | ||
Title: {{ loan.document.title_text }} | ||
Barcode: {{ loan.document.barcode }} | ||
Location: {{ loan.document.library_name }} / {{ loan.document.location_name }} | ||
{%- if loan.document.call_numbers %} | ||
Call number: {{ loan.document.call_numbers | join(' | ') }} | ||
{%- endif %} | ||
|
||
Pick up location: {{ loan.pickup_name }} | ||
Patron: {{ loan.patron.first_name }} {{ loan.patron.last_name }} | ||
{%- if loan.patron.barcode %} - {{ loan.patron.barcode | join(', ') }}{%- endif %} | ||
Request expiration: {{ loan.request_expire_date }} | ||
|
||
{% endfor %} |
17 changes: 17 additions & 0 deletions
17
rero_ils/modules/notifications/templates/email/at_desk/fre.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Exemplaire au bureau de prêt | ||
|
||
{% for loan in loans -%} | ||
Date: {{ loan.creation_date }} | ||
Titre: {{ loan.document.title_text }} | ||
Code-barres: {{ loan.document.barcode }} | ||
Localisation: {{ loan.document.library_name }} / {{ loan.document.location_name }} | ||
{%- if loan.document.call_numbers %} | ||
Cote: {{ loan.document.call_numbers | join(' | ') }} | ||
{%- endif %} | ||
|
||
Lieu de retrait: {{ loan.pickup_name }} | ||
Lecteur: {{ loan.patron.first_name }} {{ loan.patron.last_name }} | ||
{%- if loan.patron.barcode %} - {{ loan.patron.barcode | join(', ') }}{%- endif %} | ||
Expiration de la demande: {{ loan.request_expire_date }} | ||
|
||
{% endfor %} |
17 changes: 17 additions & 0 deletions
17
rero_ils/modules/notifications/templates/email/at_desk/ger.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Exemplar an der Ausleihtheke | ||
|
||
{% for loan in loans %} | ||
Datum: {{ loan.creation_date }} | ||
Titel: {{ loan.document.title_text }} | ||
Strichcode: {{ loan.document.barcode }} | ||
Standort: {{ loan.document.library_name }} / {{ loan.document.location_name }} | ||
{%- if loan.document.call_numbers %} | ||
Signatur: {{ loan.document.call_numbers | join(' | ') }} | ||
{%- endif %} | ||
|
||
Abholort: {{ loan.pickup_name }} | ||
Leser: {{ loan.patron.first_name }} {{ loan.patron.last_name }} | ||
{%- if loan.patron.barcode %} - {{ loan.patron.barcode | join(', ') }}{%- endif %} | ||
Ablauf der bestellung: {{ loan.request_expire_date }} | ||
|
||
{% endfor %} |
18 changes: 18 additions & 0 deletions
18
rero_ils/modules/notifications/templates/email/at_desk/ita.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Esemplare al banco prestiti | ||
|
||
{% for loan in loans %} | ||
Data: {{ loan.creation_date }} | ||
Titolo: {{ loan.document.title_text }} | ||
Codice a barre: {{ loan.document.barcode }} | ||
Localizzazione: {{ loan.document.library_name }} / {{ loan.document.location_name }} | ||
{%- if loan.document.call_numbers %} | ||
Segnatura: {{ loan.document.call_numbers | join(' | ') }} | ||
{%- endif %} | ||
|
||
Punto di ritiro: {{ loan.pickup_name }} | ||
Lettore: {{ loan.patron.first_name }} {{ loan.patron.last_name }} | ||
{%- if loan.patron.barcode %} - {{ loan.patron.barcode | join(', ') }}{%- endif %} | ||
Scadenza della richiesta: {{ loan.request_expire_date }} | ||
|
||
|
||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.