Applied the or_next utility to the set local route of the test site.

This commit is contained in:
依瑪貓 2023-05-17 19:54:13 +08:00
parent 482a0faa23
commit a691cfd2da

View File

@ -19,10 +19,12 @@
"""
from babel import Locale
from flask import request, session, current_app, Blueprint, Response, \
redirect, url_for, Flask
redirect, Flask
from flask_babel import Babel
from werkzeug.datastructures import LanguageAccept
from accounting.utils.next_uri import or_next
bp: Blueprint = Blueprint("locale", __name__, url_prefix="/")
@ -68,9 +70,7 @@ def set_locale() -> Response:
all_linguas: dict[str, str] = get_all_linguas()
if "locale" in request.form and request.form["locale"] in all_linguas:
session["locale"] = request.form["locale"]
if "next" in request.form:
return redirect(request.form["next"])
return redirect(url_for("home.home"))
return redirect(or_next("/"))
def get_all_linguas() -> dict[str, str]: