mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(fastapi): add /account/{username}/comments
This commit contains a base template of account comments in sorted order (based on ColumnTS.desc). Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
9fd07c36eb
commit
adb6252f85
3 changed files with 116 additions and 0 deletions
|
@ -624,6 +624,22 @@ async def account(request: Request, username: str):
|
|||
return render_template(request, "account/show.html", context)
|
||||
|
||||
|
||||
@router.get("/account/{username}/comments")
|
||||
@auth_required(redirect="/account/{username}/comments")
|
||||
async def account_comments(request: Request, username: str):
|
||||
user = db.query(models.User).filter(
|
||||
models.User.Username == username
|
||||
).first()
|
||||
if not user:
|
||||
raise HTTPException(status_code=HTTPStatus.NOT_FOUND)
|
||||
|
||||
context = make_context(request, "Accounts")
|
||||
context["username"] = username
|
||||
context["comments"] = user.package_comments.order_by(
|
||||
models.PackageComment.CommentTS.desc())
|
||||
return render_template(request, "account/comments.html", context)
|
||||
|
||||
|
||||
@router.get("/accounts")
|
||||
@auth_required(True, redirect="/accounts")
|
||||
@account_type_required({account_type.TRUSTED_USER,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue