remove g.user from before request

This commit is contained in:
Ozzie Isaacs
2023-02-04 11:18:43 +01:00
parent 1c3b69c710
commit 98da7dd5b0
22 changed files with 105 additions and 104 deletions

View File

@@ -1,7 +1,8 @@
from babel import negotiate_locale
from flask_babel import Babel, Locale
from babel.core import UnknownLocaleError
from flask import request, g
from flask import request
from flask_login import current_user
from . import logger
@@ -11,10 +12,10 @@ babel = Babel()
def get_locale():
# if a user is logged in, use the locale from the user settings
user = getattr(g, 'user', None)
if user is not None and hasattr(user, "locale"):
if user.name != 'Guest': # if the account is the guest account bypass the config lang settings
return user.locale
if current_user is not None and hasattr(current_user, "locale"):
# if the account is the guest account bypass the config lang settings
if current_user.name != 'Guest':
return current_user.locale
preferred = list()
if request.accept_languages: