diff options
| author | rebecca <ubq323@ubq323.website> | 2026-10-31 15:38:10 +0000 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-10-31 15:38:10 +0000 |
| commit | 67b4bc9e66645055d1d51cd6e60d23929268118b (patch) | |
| tree | 48ce71ea6a8292ff65391b4b4c05494dcba37a6f | |
| parent | 0765aa2fa9437944b1e2a236023aa880f1a6b8da (diff) | |
when editing or deleting post, return back to the post, not the start of the thread
| -rw-r--r-- | apioforum/templates/delete_post.html | 2 | ||||
| -rw-r--r-- | apioforum/templates/edit_post.html | 2 | ||||
| -rw-r--r-- | 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 @@ <form method="post"> <p>confirm delete?</p> <input type="submit" value="delete"> -<a href="{{url_for('thread.view_thread',thread_id=post.thread)}}">cancel</a> +<a href="{{post_jump(post.id)}}">cancel</a> </form> {% 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 @@ <textarea class="new-post-box" name="newcontent">{{post.content}}</textarea> <p>confirm edit?</p> <input type="submit" value="confirm"> -<a href="{{url_for('thread.view_thread',thread_id=post.thread)}}">cancel</a> +<a href="{{post_jump(post.id)}}">cancel</a> </form> {% 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) |
