Added the editor2 user to the test site.
This commit is contained in:
		| @@ -91,9 +91,9 @@ def create_app(is_testing: bool = False) -> Flask: | |||||||
|             return user.id |             return user.id | ||||||
|  |  | ||||||
|     can_view: t.Callable[[], bool] = lambda: auth.current_user() is not None \ |     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 \ |     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(), |     accounting.init_app(app, user_utils=UserUtils(), | ||||||
|                         can_view_func=can_view, can_edit_func=can_edit) |                         can_view_func=can_view, can_edit_func=can_edit) | ||||||
|  |  | ||||||
| @@ -106,7 +106,7 @@ def init_db_command() -> None: | |||||||
|     """Initializes the database.""" |     """Initializes the database.""" | ||||||
|     db.create_all() |     db.create_all() | ||||||
|     from .auth import User |     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: |         if User.query.filter(User.username == username).first() is None: | ||||||
|             db.session.add(User(username=username)) |             db.session.add(User(username=username)) | ||||||
|     db.session.commit() |     db.session.commit() | ||||||
|   | |||||||
| @@ -58,7 +58,8 @@ def login() -> redirect: | |||||||
|  |  | ||||||
|     :return: The redirection to the home page. |     :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")) |         return redirect(url_for("auth.login")) | ||||||
|     session["user"] = request.form.get("username") |     session["user"] = request.form.get("username") | ||||||
|     return redirect(url_for("home.home")) |     return redirect(url_for("home.home")) | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ First written: 2023/1/27 | |||||||
|   <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> |   <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> | ||||||
|   <button class="btn btn-primary" type="submit" name="username" value="viewer">{{ _("Viewer") }}</button> |   <button class="btn btn-primary" type="submit" name="username" value="viewer">{{ _("Viewer") }}</button> | ||||||
|   <button class="btn btn-primary" type="submit" name="username" value="editor">{{ _("Editor") }}</button> |   <button class="btn btn-primary" type="submit" name="username" value="editor">{{ _("Editor") }}</button> | ||||||
|  |   <button class="btn btn-primary" type="submit" name="username" value="editor2">{{ _("Editor2") }}</button> | ||||||
|   <button class="btn btn-primary" type="submit" name="username" value="nobody">{{ _("Nobody") }}</button> |   <button class="btn btn-primary" type="submit" name="username" value="nobody">{{ _("Nobody") }}</button> | ||||||
| </form> | </form> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,8 +9,8 @@ msgid "" | |||||||
| msgstr "" | msgstr "" | ||||||
| "Project-Id-Version: Mia! Accounting Flask Demonstration 0.0.0\n" | "Project-Id-Version: Mia! Accounting Flask Demonstration 0.0.0\n" | ||||||
| "Report-Msgid-Bugs-To: imacat@mail.imacat.idv.tw\n" | "Report-Msgid-Bugs-To: imacat@mail.imacat.idv.tw\n" | ||||||
| "POT-Creation-Date: 2023-01-28 13:42+0800\n" | "POT-Creation-Date: 2023-02-06 23:25+0800\n" | ||||||
| "PO-Revision-Date: 2023-01-28 13:42+0800\n" | "PO-Revision-Date: 2023-02-06 23:26+0800\n" | ||||||
| "Last-Translator: imacat <imacat@mail.imacat.idv.tw>\n" | "Last-Translator: imacat <imacat@mail.imacat.idv.tw>\n" | ||||||
| "Language: zh_Hant\n" | "Language: zh_Hant\n" | ||||||
| "Language-Team: zh_Hant <imacat@mail.imacat.idv.tw>\n" | "Language-Team: zh_Hant <imacat@mail.imacat.idv.tw>\n" | ||||||
| @@ -51,6 +51,10 @@ msgid "Editor" | |||||||
| msgstr "記帳者" | msgstr "記帳者" | ||||||
|  |  | ||||||
| #: tests/test_site/templates/login.html:32 | #: tests/test_site/templates/login.html:32 | ||||||
|  | msgid "Editor2" | ||||||
|  | msgstr "記帳者2" | ||||||
|  |  | ||||||
|  | #: tests/test_site/templates/login.html:33 | ||||||
| msgid "Nobody" | msgid "Nobody" | ||||||
| msgstr "沒有權限者" | msgstr "沒有權限者" | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user