def addCommentToNews(): with dbapi2.connect(app.config['dsn']) as connection: news_id = "" if(request.form["action"] == "Add Comment"): _newsid = request.form['newsid'] user_id = session.get('loggedUser') dbmanager.addComment(user_id,_newsid,request.form['comment_title'], request.form['comment_content'],datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), connection) return redirect(url_for('newsDetail', newsid = _newsid))
def comment(): with dbapi2.connect(app.config['dsn']) as connection: if(request.method == 'GET'): _commentList = dbmanager.getComments("null",connection) return render_template('comment.html', commentList = _commentList) if(request.form["action"] == "Add Comment"): dbmanager.addComment(request.form['comment_username'], request.form['comment_title'], request.form['comment_content'], request.form['comment_date']) return redirect(url_for('comment')) if(request.form["action"] == "Delete"): dbmanager.deleteComment(request.form['id']) return redirect(url_for('comment'))