From a22179258cb5318f0b027f62dc51f833d5d1781f Mon Sep 17 00:00:00 2001 From: Trim21 Date: Wed, 21 Aug 2024 04:18:44 +0800 Subject: [PATCH] show personal link on user detail page --- server/__init__.py | 8 +++++--- .../templates/{index.html.jinja2 => list.html.jinja2} | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) rename server/templates/{index.html.jinja2 => list.html.jinja2} (91%) diff --git a/server/__init__.py b/server/__init__.py index a6c049e..951ecf4 100644 --- a/server/__init__.py +++ b/server/__init__.py @@ -77,7 +77,7 @@ async def index(request: Request) -> Template: "select * from patch where from_user_id = $1 and deleted_at is NULL order by created_at desc", request.auth.user_id, ) - return Template("index.html.jinja2", context={"rows": rows, "auth": request.auth}) + return Template("list.html.jinja2", context={"rows": rows, "auth": request.auth}) rows = await pg.fetch( """ @@ -91,7 +91,7 @@ async def index(request: Request) -> Template: rows.sort(key=__index_row_sorter, reverse=True) return Template( - "index.html.jinja2", + "list.html.jinja2", context={"rows": rows, "auth": request.auth}, ) @@ -102,7 +102,9 @@ async def show_user(user_id: int, request: Request) -> Template: "select * from patch where from_user_id = $1 and deleted_at is NULL order by created_at desc", user_id, ) - return Template("index.html.jinja2", context={"rows": rows, "auth": request.auth}) + 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]: diff --git a/server/templates/index.html.jinja2 b/server/templates/list.html.jinja2 similarity index 91% rename from server/templates/index.html.jinja2 rename to server/templates/list.html.jinja2 index a067312..4bfeaf5 100644 --- a/server/templates/index.html.jinja2 +++ b/server/templates/list.html.jinja2 @@ -8,10 +8,16 @@ text-overflow: ellipsis; } - {% if not auth.allow_edit %} + {% if user_id is defined %}
- 添加Patch +

用户 {{ user_id }} 的个人主页

+ {% else %} + {% if not auth.allow_edit %} +
+ 添加Patch +
+ {% endif %} {% endif %}