From 9594b7f9e8867d4fbd88d80ce98af1f41908d94d Mon Sep 17 00:00:00 2001 From: Trim21 Date: Wed, 21 Aug 2024 04:34:43 +0800 Subject: [PATCH] show contrib history and review history --- server/__init__.py | 16 ++++++++++++++-- server/templates/patch.html.jinja2 | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server/__init__.py b/server/__init__.py index 25bd12f..a46b300 100644 --- a/server/__init__.py +++ b/server/__init__.py @@ -97,7 +97,7 @@ async def index(request: Request) -> Template: @litestar.get("/contrib/{user_id:int}", guards=[require_user_login]) -async def show_user(user_id: int, request: Request) -> Template: +async def show_user_contrib(user_id: int, request: Request) -> Template: rows = await pg.fetch( "select * from patch where from_user_id = $1 and deleted_at is NULL order by created_at desc", user_id, @@ -107,6 +107,17 @@ async def show_user(user_id: int, request: Request) -> Template: ) +@litestar.get("/review/{user_id:int}", guards=[require_user_login]) +async def show_user_review(user_id: int, request: Request) -> Template: + rows = await pg.fetch( + "select * from patch where wiki_user_id = $1 and deleted_at is NULL order by created_at desc", + user_id, + ) + return Template( + "list.html.jinja2", context={"rows": rows, "auth": request.auth, "user_id": user_id} + ) + + def __index_row_sorter(r: asyncpg.Record) -> tuple[int, datetime]: if r["state"] == PatchState.Pending: return 1, r["created_at"] @@ -198,7 +209,8 @@ def internal_error_handler(_: Request, exc: Exception) -> Response[Any]: app = litestar.Litestar( [ index, - show_user, + show_user_review, + show_user_contrib, login, callback, suggest_ui, diff --git a/server/templates/patch.html.jinja2 b/server/templates/patch.html.jinja2 index 2887e39..a9f1d27 100644 --- a/server/templates/patch.html.jinja2 +++ b/server/templates/patch.html.jinja2 @@ -110,7 +110,7 @@ {% elif patch.state == 1 %}
-

已被 已被 {{ patch.wiki_user_id }} 接受

@@ -118,7 +118,7 @@ {% elif patch.state == 2 %}