Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acquisition: fix default vendor language #3465

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 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,9 @@ 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