def comment(u, cid): if current_user.is_anonymous(): abort(403) try: comic = get_comic_query(u).filter_by(id=cid).one() except NoResultFound: abort(404) form = CommentForm() if form.validate_on_submit(): if form.anonymous.data: name = "Anonymous" else: name = current_user.username post = Post(name, form.comment.data, "", None) post.thread = comic.thread image = form.datafile.file if image: post.filename = chan_filename(image) save_file(post.fp(), image) db.session.add(post) db.session.commit() return redirect(url_for_comic(comic))
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)