예제 #1
0
def add_reply(parent_id):
    error = None
    if user.is_logged_in():
        if request.method == 'POST':
            result = database.insert_post(request.form['title'],
                                          request.form['content'],
                                          request.form['author'],
                                          0,
                                          parent_id,
                                          0)
            if result[0]:
                flash('Post created.')
                redir = request.args.get('redirect', parent_id)
                return redirect(url_for('display_post',
                                        post_id=redir))
            else:
                error = result[1]
        return render_user_page('edit_post.html',
                                error=error, parent=parent_id)
    else:
        return redirect(url_for('display_news'))
예제 #2
0
def add_post():
    error = None
    if user.is_logged_in():
        if request.method == 'POST':
            if user.is_admin():
                 pinned = request.form.get('pinned', 0)
            else:
                 pinned = 0
            result = database.insert_post(request.form['title'],
                                          request.form['content'],
                                          request.form['author'],
                                          0,
                                          None,
                                          pinned)
            if result[0]:
                flash('Post created.')
                return redirect(url_for('display_threads'))
            else:
                error = result[1]
        return render_user_page('edit_post.html', error=error)
    else:
        return redirect(url_for('display_news'))