Skip to content

Commit

Permalink
show contrib history and review history
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Aug 20, 2024
1 parent f1baeda commit 9594b7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"]
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions server/templates/patch.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@
{% elif patch.state == 1 %}
<hr>
<div class="col">
<h2> 已被 <a href="https://bgm.tv/user/{{ patch.wiki_user_id }}"
<h2> 已被 <a href="/review/{{ patch.wiki_user_id }}"
target="_blank">{{ patch.wiki_user_id }}</a>
<span class="badge bg-success"> 接受 </span>
</h2>
</div>
{% elif patch.state == 2 %}
<hr>
<div class="col">
<h3> 已被 <a href="https://bgm.tv/user/{{ patch.wiki_user_id }}"
<h3> 已被 <a href="/review/{{ patch.wiki_user_id }}"
target="_blank">{{ patch.wiki_user_id }}</a>
<span class="badge bg-danger"> 拒绝 </span>
</h3>
Expand Down

0 comments on commit 9594b7f

Please sign in to comment.