Пример #1
0
def comment_is_pinned(comment_details, viewer):
    """
    `viewer` should be request.user - the user viewing the comment.

    Returns "pinned" if pinned, else None.
    """
    if not isinstance(comment_details, CommentDetails):
        comment_details = CommentDetails(comment_details)
    return 'pinned' if comment_details.is_pinned(viewer) else None
Пример #2
0
    def __init__(self, comment_details):
        """ `comment_details` can be either the parent comment, or any comment within the thread. """
        from canvas.details_models import CommentDetails

        if getattr(comment_details, 'parent_id', None):
            op = CommentDetails.from_id(comment_details.parent_id)
        else:
            op = comment_details
            if not isinstance(op, CommentDetails):
                op = CommentDetails(comment_details)
        self.op = op