def threadcomment(b, thread): form = ChanForm() if not form.validate_on_submit(): return "Error" if "datafile" in request.files: filename = save_file(request.files["datafile"]) else: filename = "" post = Post(form.name.data, form.comment.data, form.email.data, filename) post.threadid = thread db.session.add(post) db.session.commit() email = form.email.data if email == "noko": if request.referrer: url = request.referrer else: url = url_for("osuchan.showthread", board=b, tid=thread) else: url = url_for("osuchan.showboard", board=b) return render_template("oc/redirect.html", url=url)
def comment(b): form = ChanForm() if not form.validate_on_submit(): return "Error" if "datafile" not in request.files: return "You forgot to select a file to upload" filename = save_file(request.files["datafile"]) # Create thread and first post, inserting them together. thread = Thread(b, form.subject.data, form.name.data) post = Post(form.name.data, form.comment.data, form.email.data, filename) thread.posts = [post] db.session.add(thread) db.session.commit() email = form.email.data if email == "noko": if request.referrer: url = request.referrer else: url = url_for("osuchan.showthread", board=b, tid=thread) else: url = url_for("osuchan.showboard", board=b) return render_template("oc/redirect.html", url=url)