From 7873e16cc316dc72bd22978905d3c7996c65ac26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 6 Feb 2023 23:28:21 +0800 Subject: [PATCH] Added the editor2 user to the test site. --- tests/test_site/__init__.py | 6 +++--- tests/test_site/auth.py | 3 ++- tests/test_site/templates/login.html | 1 + .../translations/zh_Hant/LC_MESSAGES/messages.po | 8 ++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/test_site/__init__.py b/tests/test_site/__init__.py index 32a90ab..941af29 100644 --- a/tests/test_site/__init__.py +++ b/tests/test_site/__init__.py @@ -91,9 +91,9 @@ def create_app(is_testing: bool = False) -> Flask: return user.id can_view: t.Callable[[], bool] = lambda: auth.current_user() is not None \ - and auth.current_user().username in ["viewer", "editor"] + and auth.current_user().username in ["viewer", "editor", "editor2"] can_edit: t.Callable[[], bool] = lambda: auth.current_user() is not None \ - and auth.current_user().username == "editor" + and auth.current_user().username in ["editor", "editor2"] accounting.init_app(app, user_utils=UserUtils(), can_view_func=can_view, can_edit_func=can_edit) @@ -106,7 +106,7 @@ def init_db_command() -> None: """Initializes the database.""" db.create_all() from .auth import User - for username in ["viewer", "editor", "nobody"]: + for username in ["viewer", "editor", "editor2", "nobody"]: if User.query.filter(User.username == username).first() is None: db.session.add(User(username=username)) db.session.commit() diff --git a/tests/test_site/auth.py b/tests/test_site/auth.py index 44fbeab..de8374c 100644 --- a/tests/test_site/auth.py +++ b/tests/test_site/auth.py @@ -58,7 +58,8 @@ def login() -> redirect: :return: The redirection to the home page. """ - if request.form.get("username") not in ["viewer", "editor", "nobody"]: + if request.form.get("username") not in ["viewer", "editor", "editor2", + "nobody"]: return redirect(url_for("auth.login")) session["user"] = request.form.get("username") return redirect(url_for("home.home")) diff --git a/tests/test_site/templates/login.html b/tests/test_site/templates/login.html index 0b9db75..edf20eb 100644 --- a/tests/test_site/templates/login.html +++ b/tests/test_site/templates/login.html @@ -29,6 +29,7 @@ First written: 2023/1/27 + diff --git a/tests/test_site/translations/zh_Hant/LC_MESSAGES/messages.po b/tests/test_site/translations/zh_Hant/LC_MESSAGES/messages.po index 2bc323f..51553cf 100644 --- a/tests/test_site/translations/zh_Hant/LC_MESSAGES/messages.po +++ b/tests/test_site/translations/zh_Hant/LC_MESSAGES/messages.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: Mia! Accounting Flask Demonstration 0.0.0\n" "Report-Msgid-Bugs-To: imacat@mail.imacat.idv.tw\n" -"POT-Creation-Date: 2023-01-28 13:42+0800\n" -"PO-Revision-Date: 2023-01-28 13:42+0800\n" +"POT-Creation-Date: 2023-02-06 23:25+0800\n" +"PO-Revision-Date: 2023-02-06 23:26+0800\n" "Last-Translator: imacat \n" "Language: zh_Hant\n" "Language-Team: zh_Hant \n" @@ -51,6 +51,10 @@ msgid "Editor" msgstr "記帳者" #: tests/test_site/templates/login.html:32 +msgid "Editor2" +msgstr "記帳者2" + +#: tests/test_site/templates/login.html:33 msgid "Nobody" msgstr "沒有權限者"