Example #1
0
def comment_reply():
    """Comment Reply Action.

    Used for reply guests comment and send notification email.

    Methods:
        POST

    Args:
        author: guest_name
        did: diaryObjectID
        title: diary_title
        email: guest_email
        content: reply content

    Returns:
        status: {success: true/false , reason: Exception}
    """
    if request.method == 'POST':
        author = request.form['author']
        did = request.form['did']
        email = request.form['email']
        content = request.form['content']

        return CommentDispatcher().reply_comment(author, did, email, content)
Example #2
0
def comment_list(page_num):
    """Admin Comments list page.

    Used for list all comments.

    Methods:
        GET

    Args:
        page_num: int

    Returns:
        comments object
    """
    page_size = 20

    start = (int(page_num) - 1) * page_size

    end = start + page_size

    prev, next, comments = CommentDispatcher().get_comment_list(start, end)

    return render_template(templates["comment_list"],
                           comments=comments,
                           prev=prev,
                           next=next,
                           page_num=page_num)
Example #3
0
def comment_del(comment_id):
    """Admin Comment Delete Action

    Used for delete Comment.Del comment from DiaryCommentEm and CommentDB

    Methods:
        GET

    Args:
        comment_id: CommentObjectedID

    Returns:
        none
    """
    CommentDispatcher().del_comment_by_id(comment_id)

    return redirect(url_for("admin.comment_list"))
Example #4
0
def comment_add():
    """ Comment Add AJAX Post Action.

    designed for ajax post and send reply email for admin

    Args:
        username: guest_name
        did: diary ObjectedId
        email: guest_email
        content: comment content

    Return:
        email_status: success
    """
    if request.method == 'POST':
        author = request.form['username']
        diary_id = request.form['did']
        email = request.form['email']
        content = request.form['comment']

        return CommentDispatcher().add_comment(author, diary_id, email, content)