Copy locale to User model

This commit is contained in:
rubenwardy 2022-01-25 01:22:47 +00:00
parent 3b354de2fc
commit 95b3c66366

@ -131,6 +131,14 @@ def get_locale():
locale = request.cookies.get("locale") locale = request.cookies.get("locale")
if locale in locales: if locale in locales:
if current_user.is_authenticated:
new_session = models.db.create_session({})()
new_session.query(models.User) \
.filter(models.User.username == current_user.username) \
.update({ "locale": locale })
new_session.commit()
new_session.close()
return locale return locale
return request.accept_languages.best_match(locales) return request.accept_languages.best_match(locales)