示例#1
0
def starred_comments_gallery(user, offset='top', direction='next'):
    stars = CommentSticker.objects.filter(user=user).order_by('-timestamp')
    pagination = Paginator(stars, knobs.COMMENTS_PER_PAGE, offset=offset, direction=direction)

    comments = CachedCall.multicall([QuestComment.details_by_id(id_)
                                     for id_
                                     in pagination.items.values_list('comment_id', flat=True)])

    return comments, pagination
示例#2
0
def explore_comment_details(viewer=None):
    comments = CachedCall.multicall([
        QuestComment.details_by_id(id_, promoter=QuestCommentExploreDetails)
        for id_ in preloaded_explore_comment_ids()
    ])

    add_viewer_has_starred_field(comments, viewer=viewer)

    return comments
示例#3
0
def starred_comments_gallery(user, offset='top', direction='next'):
    stars = CommentSticker.objects.filter(user=user).order_by('-timestamp')
    pagination = Paginator(stars,
                           knobs.COMMENTS_PER_PAGE,
                           offset=offset,
                           direction=direction)

    comments = CachedCall.multicall([
        QuestComment.details_by_id(id_)
        for id_ in pagination.items.values_list('comment_id', flat=True)
    ])

    return comments, pagination
示例#4
0
def quest_comments(request, quest_id, force_comment_id=None):
    quest = get_object_or_404(Quest, id=quest_id)

    # Exclude curated comments here since we ignore curation status for forced comments, below.
    comments = QuestComment.objects.filter(parent_comment=quest).exclude(visibility=Visibility.CURATED)
    comments = comments.order_by('-id')

    comments = comments[:knobs.COMMENTS_PER_PAGE]
    comments = CachedCall.queryset_details(comments)

    forced_comment = None
    if force_comment_id:
        for comment in comments:
            if str(comment.id) == str(force_comment_id):
                forced_comment = comment
                break

    if force_comment_id and forced_comment is None:
        forced_comment = QuestComment.details_by_id(force_comment_id)()

    if forced_comment is not None and str(forced_comment.id) not in [str(comment.id) for comment in comments]:
        comments.append(forced_comment)

    return {'comments': comments}
示例#5
0
 def from_id(cls, comment_id):
     from drawquest.apps.quest_comments.models import QuestComment
     return QuestComment.details_by_id(comment_id)()
示例#6
0
    def from_id(cls, comment_id):
        from drawquest.apps.quest_comments.models import QuestComment

        return QuestComment.details_by_id(comment_id, promoter=cls)()
示例#7
0
def explore_comment_details(viewer=None):
    comments = CachedCall.multicall([QuestComment.details_by_id(id_, promoter=QuestCommentExploreDetails) for id_ in preloaded_explore_comment_ids()])

    add_viewer_has_starred_field(comments, viewer=viewer)

    return comments