def create_post(): post = request.form post_dict = { 'user': post['user'], 'write_date': get_current_date(), 'title': post['title'], 'contents': post['contents'] } mongo.insert_one(mongo_conn, post_dict) return render_template('index.html', board_dict=mongo.find_boards(mongo_conn))
def edit_post(): post = request.form post_id = post['post_id'] post_dict = { 'user': post['user'], 'write_date': post['write_date'], 'title': post['title'], 'contents': post['contents'] } mongo.update_boards(mongo_conn, post_id, post_dict) return render_template('index.html', board_dict=mongo.find_boards(mongo_conn))
def del_post(post_id): mongo.del_boards(mongo_conn, post_id) return render_template('index.html', board_dict=mongo.find_boards(mongo_conn))
def template_posts(post_id): board_dict = dict() boards = mongo.find_boards(mongo_conn) if post_id in boards: board_dict = boards[post_id] return render_template('post.html', board_dict=board_dict, post_id=post_id)
def template_boards(): return render_template('index.html', board_dict=mongo.find_boards(mongo_conn))