예제 #1
0
def threadcomment(board, 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=board, tid=thread)
    else:
        url = url_for("osuchan.showboard", board=board)

    return render_template("oc/redirect.html", url=url)
예제 #2
0
def comment(board):
    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(board, 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=board, tid=thread)
    else:
        url = url_for("osuchan.showboard", board=board)

    return render_template("oc/redirect.html", url=url)