diff options
Diffstat (limited to 'apioforum/forum.py')
| -rw-r--r-- | apioforum/forum.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py index a955ed5..b731a24 100644 --- a/apioforum/forum.py +++ b/apioforum/forum.py @@ -280,9 +280,17 @@ def create_thread(forum): if forum is None: flash("that forum doesn't exist") return redirect(url_for('index')) + + if "type" in request.args: + thread_type = request.args["type"] + else: + thread_type = "thread" + thread_type = thread_type.replace('_', " ") + if thread_type != "thread" and thread_type != "wiki page": + abort(404) if g.user is None: - flash("you need to be logged in to create a thread") + flash("you need to be logged in to create a " + thread_type) return redirect(url_for('index')) if request.method == "POST": @@ -298,15 +306,21 @@ def create_thread(forum): lock = int(request.form.get('lock','0')) cur = db.cursor() cur.execute( - """INSERT INTO threads (title,creator,created,updated,forum,locked) - VALUES (?,?,current_timestamp,current_timestamp,?,?);""", - (title,g.user,forum['id'],lock) + """INSERT INTO threads (title,creator,created,updated,forum,locked,type) + VALUES (?,?,current_timestamp,current_timestamp,?,?,?);""", + (title,g.user,forum['id'],lock,thread_type) ) thread_id = cur.lastrowid cur.execute( "INSERT INTO posts (thread,created,author,content) VALUES (?,current_timestamp,?,?);", (thread_id,g.user,content) ) + db.execute(""" + INSERT INTO revisions (post,author,content,time,comment) + VALUES (?,?,?,current_timestamp,?); + """, (cur.lastrowid,g.user,content,"(created)")) + if thread_type == "wiki page": + db.execute("UPDATE posts SET wiki = 1 WHERE id = ?;", (cur.lastrowid,)) thread = {'id': thread_id, 'forum': forum['id']} apply_selected_tags(thread, request.form) db.commit() @@ -321,6 +335,7 @@ def create_thread(forum): return render_template("config_thread.html", forum=forum, + thread_type=thread_type, avail_tags=get_avail_tags(forum['id'])) @forum_route("roles",methods=("GET","POST")) |
