return 404 where it makes sense
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from flask import (
|
||||
Blueprint, render_template, request, redirect, url_for, flash
|
||||
Blueprint, render_template, request, redirect, url_for, flash,
|
||||
abort,
|
||||
)
|
||||
from .users import login_required, mod_only, get_active_user, is_logged_in
|
||||
from ..db import db
|
||||
@@ -32,7 +33,8 @@ def thread(slug):
|
||||
POSTS_PER_PAGE = 10
|
||||
thread = Threads.find({"slug": slug})
|
||||
if not thread:
|
||||
return redirect(url_for('topics.all_topics'))
|
||||
abort(404)
|
||||
return
|
||||
|
||||
post_count = Posts.count({"thread_id": thread.id})
|
||||
page_count = max(math.ceil(post_count / POSTS_PER_PAGE), 1)
|
||||
@@ -86,7 +88,8 @@ def thread(slug):
|
||||
def reply(slug):
|
||||
thread = Threads.find({"slug": slug})
|
||||
if not thread:
|
||||
return redirect(url_for('topics.all_topics'))
|
||||
abort(404)
|
||||
return
|
||||
user = get_active_user()
|
||||
if user.is_guest():
|
||||
return redirect(url_for('.thread', slug=slug))
|
||||
@@ -148,7 +151,8 @@ def lock(slug):
|
||||
user = get_active_user()
|
||||
thread = Threads.find({'slug': slug})
|
||||
if not thread:
|
||||
return redirect(url_for('topics.all_topics'))
|
||||
abort(404)
|
||||
return
|
||||
if not ((thread.user_id == user.id) or user.is_mod()):
|
||||
return redirect(url_for('.thread', slug=slug))
|
||||
target_op = request.form.get('target_op')
|
||||
@@ -165,7 +169,8 @@ def sticky(slug):
|
||||
user = get_active_user()
|
||||
thread = Threads.find({'slug': slug})
|
||||
if not thread:
|
||||
return redirect(url_for('topics.all_topics'))
|
||||
abort(404)
|
||||
return
|
||||
if not ((thread.user_id == user.id) or user.is_mod()):
|
||||
return redirect(url_for('.thread', slug=slug))
|
||||
target_op = request.form.get('target_op')
|
||||
|
||||
Reference in New Issue
Block a user