diff --git a/app/routes/mod.py b/app/routes/mod.py index 7e25da0..a2523f5 100644 --- a/app/routes/mod.py +++ b/app/routes/mod.py @@ -14,27 +14,27 @@ def mod_only(): def index(): return 'stub' -@bp.get('/topics/new') +@bp.get('/topics/new/') def new_topic(): return render_template('mod/new_topic.html') -@bp.post('/topics/new') +@bp.post('/topics/new/') def new_topic_post(): topic = Topics.new(request.form.get('name'), request.form.get('description')) return redirect(url_for('topics.topic', slug=topic.slug)) -@bp.get('/topics/sort') +@bp.get('/topics/sort/') def sort_topics(): return 'stub' -@bp.get('/topics//edit') +@bp.get('/topics//edit/') def edit_topic(topic_id): topic = Topics.find({'id': topic_id}) if not topic: abort(404) return render_template('mod/edit_topic.html', topic=topic) -@bp.post('/topics//edit') +@bp.post('/topics//edit/') def edit_topic_post(topic_id): topic = Topics.find({'id': topic_id}) if not topic: @@ -45,7 +45,7 @@ def edit_topic_post(topic_id): }) return redirect(url_for('topics.topic', slug=topic.slug)) -@bp.post('/topics//lock') +@bp.post('/topics//lock/') def lock_topic(topic_id): topic = Topics.find({'id': topic_id}) if not topic: @@ -53,7 +53,7 @@ def lock_topic(topic_id): topic.update({'is_locked': request.form.get('lock', default=0)}) return redirect(url_for('topics.topic', slug=topic.slug)) -@bp.post('/threads//move') +@bp.post('/threads//move/') def move_thread(thread_id): thread = Threads.find({'id': thread_id}) if not thread: @@ -64,7 +64,7 @@ def move_thread(thread_id): thread.update({'topic_id': target_topic.id}) return redirect(url_for('threads.thread', slug=thread.slug)) -@bp.post('/threads//lock') +@bp.post('/threads//lock/') def lock_thread(thread_id): thread = Threads.find({'id': thread_id}) if not thread: @@ -72,7 +72,7 @@ def lock_thread(thread_id): thread.update({'is_locked': request.form.get('lock')}) return redirect(url_for('threads.thread', slug=thread.slug)) -@bp.post('/threads//sticky') +@bp.post('/threads//sticky/') def sticky_thread(thread_id): thread = Threads.find({'id': thread_id}) if not thread: diff --git a/app/routes/posts.py b/app/routes/posts.py index 5c674dc..87052af 100644 --- a/app/routes/posts.py +++ b/app/routes/posts.py @@ -2,6 +2,6 @@ from flask import Blueprint bp = Blueprint('posts', __name__, url_prefix='/posts/') -@bp.get('//edit') +@bp.get('//edit/') def edit(post_id): return 'stub' diff --git a/app/routes/threads.py b/app/routes/threads.py index c845a4b..b2c23f3 100644 --- a/app/routes/threads.py +++ b/app/routes/threads.py @@ -5,7 +5,7 @@ import math bp = Blueprint('threads', __name__, url_prefix='/threads/') -@bp.get('/') +@bp.get('//') def thread(slug): thread = Threads.find({'slug': slug}) if not thread: @@ -34,7 +34,7 @@ def thread(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('//reply') +@bp.post('//reply/') @login_required def reply(slug): user = get_active_user() @@ -47,7 +47,7 @@ def reply(slug): post = Posts.new(user.id, thread.id, request.form.get('babycode_content')) return redirect(url_for('.thread', slug=slug, after=post.id, _anchor=f'post-{post.id}')) -@bp.get('//feed.atom') +@bp.get('//feed.atom/') def feed(slug): return 'stub' @@ -61,7 +61,7 @@ def new(): selected_topic = None return render_template('threads/new_thread.html', topics=topics, selected_topic=selected_topic) -@bp.post('/new') +@bp.post('/new/') @login_required def new_post(): try: diff --git a/app/routes/topics.py b/app/routes/topics.py index 0d420f9..e7c1488 100644 --- a/app/routes/topics.py +++ b/app/routes/topics.py @@ -10,13 +10,13 @@ def all_topics(): topic_list = Topics.get_list() return render_template('topics/topics.html', topics=topic_list) -@bp.get('/') +@bp.get('//') def topic(slug): topic = Topics.find({'slug': slug}) if not topic: abort(404) sort_by = request.args.get('sort_by', default=session.get('sort_by', default='activity')) - PER_PAGE = 10 + PER_PAGE = 3 threads_count = Threads.count({'topic_id': topic.id}) page_count = max(1, math.ceil(threads_count / PER_PAGE)) try: diff --git a/app/routes/users.py b/app/routes/users.py index 5a62cd2..61edaf7 100644 --- a/app/routes/users.py +++ b/app/routes/users.py @@ -18,12 +18,12 @@ def redirect_if_logged_in(destination='topics.all_topics'): return wrapper return decorator -@bp.get('/log-in') +@bp.get('/log-in/') @redirect_if_logged_in() def log_in(): return render_template('users/log_in.html') -@bp.post('/log-in') +@bp.post('/log-in/') @redirect_if_logged_in() def log_in_post(): username = request.form.get('username', default='').lower() @@ -89,7 +89,7 @@ def sign_up_post(): return redirect(url_for('topics.all_topics')) -@bp.get('/') +@bp.get('//') def user_page(username): return 'stub'