Skip to content

Commit

Permalink
fix: show user nickname in patch page
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Aug 20, 2024
1 parent f5d2720 commit fcbc2ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 13 additions & 1 deletion server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ async def get_patch(patch_id: str, request: Request) -> Template:
# not valid uuid string, just raise not-found
raise NotFoundException() from e

p = await pg.fetchrow("""select * from patch where id = $1 and deleted_at is NULL""", patch_id)
p = await pg.fetchrow(
"""select * from patch where id = $1 and deleted_at is NULL limit 1""", patch_id
)
if not p:
raise NotFoundException()

Expand Down Expand Up @@ -187,6 +189,14 @@ async def get_patch(patch_id: str, request: Request) -> Template:
)
)

reviewer = None
if patch.state != PatchState.Pending:
reviewer = await pg.fetchrow(
"select * from patch_users where user_id=$1", patch.wiki_user_id
)

submitter = await pg.fetchrow("select * from patch_users where user_id=$1", patch.from_user_id)

return Template(
"patch.html.jinja2",
context={
Expand All @@ -195,6 +205,8 @@ async def get_patch(patch_id: str, request: Request) -> Template:
"name_patch": name_patch,
"infobox_patch": infobox_patch,
"summary_patch": summary_patch,
"reviewer": reviewer,
"submitter": submitter,
},
)

Expand Down
14 changes: 7 additions & 7 deletions server/templates/patch.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
</a>
</div>
<div class="col">
<a href="/contrib/{{ patch.from_user_id }}" target="_blank"
rel="noopener">
<h3>提交者: {{ patch.from_user_id }}</h3>
<h3>
提交者: <a href="/contrib/{{ patch.from_user_id }}" target="_blank"
rel="noopener">
{{ submitter.nickname }}
</a>
</h3>
</div>
</div>


<div class="row">
<h3>修改原因</h3>
<blockquote class="blockquote" style="background-color: #f7f7f9">
Expand Down Expand Up @@ -111,15 +112,15 @@
<hr>
<div class="col">
<h2> 已被 <a href="/review/{{ patch.wiki_user_id }}"
target="_blank">{{ patch.wiki_user_id }}</a>
target="_blank">{{ reviewer.nickname }}</a>
<span class="badge bg-success"> 接受 </span>
</h2>
</div>
{% elif patch.state == 2 %}
<hr>
<div class="col">
<h3> 已被 <a href="/review/{{ patch.wiki_user_id }}"
target="_blank">{{ patch.wiki_user_id }}</a>
target="_blank">{{ reviewer.nickname }}</a>
<span class="badge bg-danger"> 拒绝 </span>
</h3>

Expand All @@ -133,7 +134,6 @@
<h2> 已过期 </h2>
</div>
{% endif %}

</div>

{% if name_patch %}
Expand Down

0 comments on commit fcbc2ef

Please sign in to comment.