add topic sorting & js to support it
This commit is contained in:
@@ -2,6 +2,7 @@ from flask import Blueprint, abort, redirect, url_for, request, render_template,
|
||||
from ..constants import InfoboxKind, PermissionLevel, MOTD_BANNED_TAGS
|
||||
from ..auth import is_logged_in, get_active_user, csrf_verified
|
||||
from ..models import Topics, Threads, Users, MOTD
|
||||
from ..db import db
|
||||
from ..lib.babycode import babycode_to_html, BABYCODE_VERSION
|
||||
from slugify import slugify
|
||||
from functools import wraps
|
||||
@@ -26,7 +27,8 @@ def admin_only(view_func):
|
||||
@bp.get('/')
|
||||
def index():
|
||||
motd = MOTD.get_all()[0] if MOTD.has_motd() else None
|
||||
return render_template('mod/panel.html', MOTD_BANNED_TAGS=MOTD_BANNED_TAGS, motd=motd)
|
||||
topics = Topics.get_list()
|
||||
return render_template('mod/panel.html', MOTD_BANNED_TAGS=MOTD_BANNED_TAGS, motd=motd, topics=topics)
|
||||
|
||||
@bp.post('/motd/set/')
|
||||
def set_motd():
|
||||
@@ -143,6 +145,15 @@ def sticky_thread(thread_id):
|
||||
thread.update({'is_stickied': request.form.get('sticky')})
|
||||
return redirect(url_for('threads.thread_by_id', thread_id=thread.id))
|
||||
|
||||
@bp.post('/threads/sort/')
|
||||
def sort_topics():
|
||||
topics_list = request.form.getlist('topics[]')
|
||||
with db.transaction():
|
||||
for new_order, topic_id in enumerate(topics_list):
|
||||
db.execute('UPDATE topics SET sort_order = ? WHERE id = ?', new_order, topic_id)
|
||||
|
||||
return redirect(url_for('.index', _anchor='sort-topics'))
|
||||
|
||||
@bp.post('/users/<int:user_id>/make-guest/')
|
||||
@csrf_verified
|
||||
def make_user_guest(user_id):
|
||||
|
||||
Reference in New Issue
Block a user