예제 #1
0
def show_new_comment(comment_pk):
	old_comment = model.get_comment_by_pk(comment_pk)
	new_comment = model.edit_comment(current_user.user_id, old_comment.post.post_pk, comment_pk, request.form.get('edited_comment'))
	new_comment_timestamp = format_date(new_comment.timestamp)
	return jsonify({
		'comment_author': new_comment.user.first_name,
		'comment_content': new_comment.content,
		'comment_timestamp': new_comment_timestamp})
예제 #2
0
def show_new_comment(comment_pk):
    old_comment = model.get_comment_by_pk(comment_pk)
    new_comment = model.edit_comment(current_user.user_id,
                                     old_comment.post.post_pk, comment_pk,
                                     request.form.get('edited_comment'))
    new_comment_timestamp = format_date(new_comment.timestamp)
    return jsonify({
        'comment_author': new_comment.user.first_name,
        'comment_content': new_comment.content,
        'comment_timestamp': new_comment_timestamp
    })
예제 #3
0
def delete_comment(comment_pk): 
	comment = model.get_comment_by_pk(comment_pk)
	comment.is_deleted = True 
	comment.post.comment_count -= 1 
	sesh.commit()
	return redirect(url_for("show_post",post_pk=comment.post_pk))
예제 #4
0
def edit_comment(comment_pk):
	comment = model.get_comment_by_pk(comment_pk)
	return jsonify({
		'comment_content': comment.content})
예제 #5
0
def delete_comment(comment_pk):
    comment = model.get_comment_by_pk(comment_pk)
    comment.is_deleted = True
    comment.post.comment_count -= 1
    sesh.commit()
    return redirect(url_for("show_post", post_pk=comment.post_pk))
예제 #6
0
def edit_comment(comment_pk):
    comment = model.get_comment_by_pk(comment_pk)
    return jsonify({'comment_content': comment.content})