Skip to content

Commit

Permalink
acquisition: fix default vendor language
Browse files Browse the repository at this point in the history
If the vendor's communication language is not defined,
we use the default language (eng).

* Closes rero#2714.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Oct 3, 2023
1 parent 6106294 commit 479816b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def _(x):
# ====
#: Default language
BABEL_DEFAULT_LANGUAGE = 'en'
RERO_ILS_APP_DEFAULT_LANGUAGE = 'eng'
#: Default time zone
BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich'
#: Other supported languages (do not include the default language in list).
Expand Down
3 changes: 2 additions & 1 deletion rero_ils/modules/acquisition/acq_orders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def order_notification_preview(order_pid):
f'"{language}" language'
current_app.logger.error(msg)
response['message'] = [{'type': 'error', 'content': msg}]
tmpl_file = 'rero_ils/vendor_order_mail/eng.tpl.txt'
language = current_app.config.get('RERO_ILS_APP_DEFAULT_LANGUAGE', 'eng')
tmpl_file = f'rero_ils/vendor_order_mail/{language}.tpl.txt'
response['preview'] = render_template(tmpl_file, order=order_data)

return jsonify(response)
Expand Down
6 changes: 5 additions & 1 deletion rero_ils/modules/notifications/subclasses/acq_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from __future__ import absolute_import, print_function

from flask import current_app
from werkzeug.utils import cached_property

from rero_ils.modules.acquisition.acq_orders.dumpers import \
Expand Down Expand Up @@ -111,7 +112,10 @@ def get_language_to_use(self):
"""Get the language to use for dispatching the notification."""
# By default, the language to use to build the notification is defined
# in the vendor setting. Override this method if needed in the future.
return self.order.vendor.get('communication_language')
return self.order.vendor.get(
'communication_language',
current_app.config.get('RERO_ILS_APP_DEFAULT_LANGUAGE', 'eng')
)

def get_template_path(self):
"""Get the template to use to render the notification."""
Expand Down

0 comments on commit 479816b

Please sign in to comment.