Esempio n. 1
0
def new_divvy(request, id_range=None):
    from_, to = get_divvy_range(id_range)
    per_page = knobs.WHITELIST_COMMENTS_PER_PAGE * (to - from_)

    comments = divvy(QuestComment.unjudged().order_by('-id')[:per_page], from_, to)

    ctx = {
        'comments': comments,
        'body_class': 'new',
        'unjudged_count': QuestComment.objects.filter(judged=False).count(),
    }
    return r2r_jinja('whitelisting/new.html', ctx, request)
Esempio n. 2
0
def new_divvy(request, id_range=None):
    from_, to = get_divvy_range(id_range)
    per_page = knobs.WHITELIST_COMMENTS_PER_PAGE * (to - from_)

    comments = divvy(QuestComment.unjudged().order_by('-id')[:per_page], from_,
                     to)

    ctx = {
        'comments': comments,
        'body_class': 'new',
        'unjudged_count': QuestComment.objects.filter(judged=False).count(),
    }
    return r2r_jinja('whitelisting/new.html', ctx, request)
Esempio n. 3
0
def _moderation_context(sections, id_range=None):
    per_page = knobs.WHITELIST_COMMENTS_PER_PAGE

    if id_range is not None:
        from_, to = get_divvy_range(id_range)
        per_page = knobs.WHITELIST_COMMENTS_PER_PAGE * (to - from_)

    comments = []
    left_per_page = per_page
    for section in sections:
        if left_per_page == 0:
            break

        incoming_comments = section[:left_per_page]
        left_per_page -= len(incoming_comments)

        if id_range is None:
            comments.extend(list(incoming_comments))
        else:
            comments.extend(list(divvy(incoming_comments, from_, to)))

    if id_range is not None:
        comments = divvy(comments, from_, to)

    try:
        auto_curate = loads(redis.get('dq:auto_curate'))
    except TypeError:
        auto_curate = False

    min_ago = time.time() - 60

    return {
        'comments': comments,
        'auto_curate_enabled': auto_curate,
        'body_class': 'moderation',
    }
Esempio n. 4
0
def _moderation_context(sections, id_range=None):
    per_page = knobs.WHITELIST_COMMENTS_PER_PAGE

    if id_range is not None:
        from_, to = get_divvy_range(id_range)
        per_page = knobs.WHITELIST_COMMENTS_PER_PAGE * (to - from_)

    comments = []
    left_per_page = per_page
    for section in sections:
        if left_per_page == 0:
            break

        incoming_comments = section[:left_per_page]
        left_per_page -= len(incoming_comments)

        if id_range is None:
            comments.extend(list(incoming_comments))
        else:
            comments.extend(list(divvy(incoming_comments, from_, to)))

    if id_range is not None:
        comments = divvy(comments, from_, to)

    try:
        auto_curate = loads(redis.get('dq:auto_curate'))
    except TypeError:
        auto_curate = False

    min_ago = time.time() - 60

    return {
        'comments': comments,
        'auto_curate_enabled': auto_curate,
        'body_class': 'moderation',
    }