Skip to content

Commit

Permalink
show personal link on user detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Aug 20, 2024
1 parent f5397aa commit a221792
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand All @@ -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},
)

Expand All @@ -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]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
text-overflow: ellipsis;
}
</style>
{% if not auth.allow_edit %}
{% if user_id is defined %}
<div class="row m-1">
<a href="/suggest">添加Patch</a>
<a href="https://bgm.tv/user/{{ user_id }}"> <h2>用户 {{ user_id }} 的个人主页</h2> </a>
</div>
{% else %}
{% if not auth.allow_edit %}
<div class="row m-1">
<a href="/suggest">添加Patch</a>
</div>
{% endif %}
{% endif %}

<div class="row mt-4">
Expand Down

0 comments on commit a221792

Please sign in to comment.