Beispiel #1
0
def bodhi_comment():
    current_time = str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
    db_session.add(BodhiComment(current_time, str( request.form['title']),
                str(request.form['text']), str(request.form['user_name']),
                int(request.form['karma']), request.form['email'] in ['false', 'False']))
    db_session.commit()
    return json.dumps(default_response)
Beispiel #2
0
def get_boji_comment(comment_id):
    c = db_session.query(BodhiComment).filter(BodhiComment.id == comment_id).first()

    if request.method == 'GET':
        comment = dict(date=str(c.date), update=c.title, text=c.text, user=c.username, karma=c.karma, send_email=c.send_email, id=c.id)
        return render_template('comment_detail.html', comment = comment)

    # stupid browsers not supporting HTTP delete calls ...
    elif request.method == 'POST':
        if request.form['request'] == 'DELETE':
            db_session.delete(c)
            db_session.commit()
            flash('Comment %d was deleted' % comment_id)
            return redirect(url_for('default_boji_comments'))

    elif request.method == 'DELETE':
        db_session.delete(c)
        db_session.commit()
        return (url_for('default_boji_comments'))
Beispiel #3
0
def clear_db():
    db_session.execute('delete from comments')
    db_session.commit()
    flash('Database was cleared')
    return redirect(url_for('default_boji_comments'))