Saved user language was not being picked up in case of non-server mode.

Because - the get_locale(...) function was being executed before any
request, and user login after first request. Hence - the values for
the labels in the Preferences are not being translated properly.

Fetch the raw value of user_language from configuration in case of
runtime/non-server mode to fix the issue.
This commit is contained in:
Alexander Lakhin
2017-10-30 18:20:25 +05:30
committed by Ashesh Vashi
parent bc0320d21e
commit 8860bc3c3e
2 changed files with 47 additions and 8 deletions

View File

@@ -473,6 +473,41 @@ class Preferences(object):
options, help_str, category_label
)
@staticmethod
def raw_value(_module, _preference, _category=None, _user_id=None):
# Find the entry for this module in the configuration database.
module = ModulePrefTable.query.filter_by(name=_module).first()
if module is None:
return None
if _category is None:
_category = _module
if _user_id is None:
_user_id = getattr(current_user, 'id', None)
if _user_id is None:
return None
cat = PrefCategoryTbl.query.filter_by(mid=module.id).filter_by(name=_category).first()
if cat is None:
return None
pref = PrefTable.query.filter_by(name=_preference).filter_by(cid=cat.id).first()
if pref is None:
return None
user_pref = UserPrefTable.query.filter_by(
pid=pref.id
).filter_by(uid=_user_id).first()
if user_pref is not None:
return user_pref.value
return None
@classmethod
def module(cls, name, create=True):
"""