From 67b4bc9e66645055d1d51cd6e60d23929268118b Mon Sep 17 00:00:00 2001 From: rebecca Date: Sat, 31 Oct 2026 15:38:10 +0000 Subject: when editing or deleting post, return back to the post, not the start of the thread --- apioforum/templates/delete_post.html | 2 +- apioforum/templates/edit_post.html | 2 +- apioforum/thread.py | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apioforum/templates/delete_post.html b/apioforum/templates/delete_post.html index 2f16598..4d52a4e 100644 --- a/apioforum/templates/delete_post.html +++ b/apioforum/templates/delete_post.html @@ -10,6 +10,6 @@

confirm delete?

-cancel +cancel
{% endblock %} diff --git a/apioforum/templates/edit_post.html b/apioforum/templates/edit_post.html index 8e8120d..275f97f 100644 --- a/apioforum/templates/edit_post.html +++ b/apioforum/templates/edit_post.html @@ -9,6 +9,6 @@

confirm edit?

-cancel +cancel {% endblock %} diff --git a/apioforum/thread.py b/apioforum/thread.py index 7723a79..59bf1c0 100644 --- a/apioforum/thread.py +++ b/apioforum/thread.py @@ -283,9 +283,11 @@ def delete_post(post_id): if post is None: flash("that post doesn't exist") return redirect("/") + + jump_url = post_jump(post_id) if post['author'] != g.user and not has_permission(thread['forum'], g.user, "p_delete_posts"): flash("you do not have permission to do that") - return redirect(url_for("thread.view_thread",thread_id=post["thread"])) + return redirect(jump_url) if request.method == "POST": db.execute(""" UPDATE posts SET @@ -294,7 +296,7 @@ def delete_post(post_id): WHERE id = ?""",(post_id,)) db.commit() flash("post deleted deletedly") - return redirect(url_for("thread.view_thread",thread_id=post["thread"])) + return redirect(jump_url) else: return render_template("delete_post.html",post=post) @@ -328,23 +330,22 @@ def edit_post(post_id): flash("that post doesn't exist") return redirect(url_for('index')) + jump_url = post_jump(post_id) if post['author'] != g.user: flash("you can only edit posts that you created") - return redirect(url_for("thread.view_thread",thread_id=post['thread'])) - # note: i am writing this while i am very tired, so probably - # come back and test this properly later + return redirect(jump_url) + if request.method == "POST": err = None newcontent = request.form['newcontent'] if len(newcontent.strip()) == 0: err="post contents can't be empty" - print(err) if err is None: db.execute( "UPDATE posts SET content = ?, edited = 1, updated = current_timestamp WHERE id = ?",(newcontent,post_id)) db.commit() flash("post edited editiously") - return redirect(post_jump(post_id)) + return redirect(jump_url) else: flash(err) return render_template("edit_post.html",post=post) -- cgit v1.2.3