From 7d1827ffc54617b58328f44e993bde6bc97fe927 Mon Sep 17 00:00:00 2001 From: moson-mo Date: Wed, 8 Mar 2023 18:40:35 +0100 Subject: [PATCH] feat: cancel button for comment editing Adds button that allows cancellation while editing a comment Signed-off-by: moson-mo --- aurweb/routers/pkgbase.py | 6 ++++++ po/aurweb.pot | 4 ++++ templates/partials/packages/comment_form.html | 5 +++++ test/test_pkgbase_routes.py | 20 +++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/aurweb/routers/pkgbase.py b/aurweb/routers/pkgbase.py index 4e018a64..6073aed5 100644 --- a/aurweb/routers/pkgbase.py +++ b/aurweb/routers/pkgbase.py @@ -293,8 +293,14 @@ async def pkgbase_comment_post( comment: str = Form(default=str()), enable_notifications: bool = Form(default=False), next: str = Form(default=None), + cancel: bool = Form(default=False), ): """Edit an existing comment.""" + if cancel: + return RedirectResponse( + f"/pkgbase/{name}#comment-{id}", status_code=HTTPStatus.SEE_OTHER + ) + pkgbase = get_pkg_or_base(name, PackageBase) db_comment = get_pkgbase_comment(pkgbase, id) diff --git a/po/aurweb.pot b/po/aurweb.pot index ff1bde8b..7e798a21 100644 --- a/po/aurweb.pot +++ b/po/aurweb.pot @@ -2354,3 +2354,7 @@ msgstr "" #: aurweb/routers/accounts.py msgid "The account has not been deleted, check the confirmation checkbox." msgstr "" + +#: templates/partials/packages/comment_form.html +msgid "Cancel" +msgstr "" diff --git a/templates/partials/packages/comment_form.html b/templates/partials/packages/comment_form.html index 9222d6e9..bf9a14d0 100644 --- a/templates/partials/packages/comment_form.html +++ b/templates/partials/packages/comment_form.html @@ -33,6 +33,11 @@ Routes: + {% if comment %} + + {% endif %} {% if not request.user.notified(pkgbase) %}