From d47ba255f180f966d7d605eb6a545890d4f72c9b Mon Sep 17 00:00:00 2001 From: Ari Archer Date: Sat, 1 Feb 2025 21:01:24 +0200 Subject: [PATCH] Add sort by newest option. Signed-off-by: Ari Archer --- src/aw/views.py | 15 +++++++++++---- src/templates/index.j2 | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/aw/views.py b/src/aw/views.py index 0c31814..6d036dc 100644 --- a/src/aw/views.py +++ b/src/aw/views.py @@ -79,13 +79,20 @@ def set_status() -> Response: def index() -> str: """Home page""" + if "newest" in flask.request.args: + comments = models.Comment.query.filter_by(confirmed=True).order_by( + models.Comment.posted.desc(), # type: ignore + ) + else: + comments = models.Comment.query.filter_by(confirmed=True).order_by( + models.Comment.score.desc(), # type: ignore + models.Comment.posted.desc(), # type: ignore + ) + return flask.render_template( "index.j2", visitor=models.Counter.first().inc().count, - comments=models.Comment.query.filter_by(confirmed=True).order_by( - models.Comment.score.desc(), # type: ignore - models.Comment.posted.desc(), # type: ignore - ), + comments=comments, status=status, comment=flask.request.args.get("gb"), ) diff --git a/src/templates/index.j2 b/src/templates/index.j2 index 2aeae73..e17b138 100644 --- a/src/templates/index.j2 +++ b/src/templates/index.j2 @@ -516,7 +516,8 @@
- Report any impersonation, illegal/graphic content, and/or anything disturbing to the owner of this website: Ari Archer. +

Report any impersonation, illegal/graphic content, and/or anything disturbing to the owner of this website: Ari Archer.

+

Sort by score | Sort by newest