def newsDetail(newsid): with dbapi2.connect(app.config['dsn']) as connection: _news = dbmanager.getNewsWithID(newsid,connection) _sponsorList = dbmanager.getSponsor(connection) _channelList = dbmanager.getChannels(connection) _info = layoutInfo(_news.getTitle(),'',_news.getImageUrl()) _comments = dbmanager.getComments(newsid,connection) return render_template('/fnews_detail.html',news = _news, info = _info, commentList = _comments, sponsorList = _sponsorList, channelList = _channelList)
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'))