only show reply form if the user can reply

This commit is contained in:
2026-04-25 23:56:46 +03:00
parent 286a3641eb
commit 612d69c157
5 changed files with 9 additions and 10 deletions

View File

@@ -58,15 +58,14 @@ def thread(thread_id, slug):
abort(404)
return render_template('threads/thread.html', thread=thread, posts=thread.get_posts(PER_PAGE, page), page=page, page_count=page_count, topic=topic, started_by=started_by, topics=Topics.get_list(), Reactions=Reactions)
@bp.post('/<int:thread_id>/reply/')
@bp.post('/<int:thread_id>/')
@login_required
def reply(thread_id):
user = get_active_user()
thread = Threads.find({'id': thread_id})
if not thread:
abort(404)
if thread.locked() and not user.is_mod():
# TODO: flash
if not user.can_post_to_thread_or_topic(thread):
return redirect(url_for('.thread_by_id', thread_id=thread_id))
post = Posts.new(user.id, thread.id, request.form.get('babycode_content'))
return redirect(url_for('.thread_by_id', thread_id=thread_id, after=post.id, _anchor=f'post-{post.id}'))
@@ -110,7 +109,7 @@ def new_post():
abort(404)
user = get_active_user()
if not user.can_post_to_topic(topic):
if not user.can_post_to_thread_or_topic(topic):
abort(404)
title = request.form.get('title')