示例#1
0
def queue_content_review(request):
    qs = (
        AutoApprovalSummary.get_content_review_queue()
        .select_related('addonapprovalscounter')
        .order_by('addonapprovalscounter__last_content_review', 'created')
    )
    return _queue(request, ContentReviewTable, 'content_review',
                  qs=qs, SearchForm=None)
示例#2
0
def queue_counts(type=None,
                 unlisted=False,
                 admin_reviewer=False,
                 limited_reviewer=False,
                 **kw):
    def construct_query(query_type, days_min=None, days_max=None):
        query = query_type.objects

        if not admin_reviewer:
            query = exclude_admin_only_addons(query)
        if days_min:
            query = query.having('waiting_time_days >=', days_min)
        if days_max:
            query = query.having('waiting_time_days <=', days_max)
        if limited_reviewer:
            query = query.having('waiting_time_hours >=',
                                 amo.REVIEW_LIMITED_DELAY_HOURS)

        return query.count

    counts = {
        'pending': construct_query(ViewPendingQueue, **kw),
        'nominated': construct_query(ViewFullReviewQueue, **kw),
        'moderated': Review.objects.all().to_moderate().count,
        'auto_approved': (AutoApprovalSummary.get_auto_approved_queue().count),
        'content_review':
        (AutoApprovalSummary.get_content_review_queue().count),
    }
    if unlisted:
        counts = {
            'all':
            (ViewUnlistedAllList.objects if admin_reviewer else
             exclude_admin_only_addons(ViewUnlistedAllList.objects)).count
        }
    rv = {}
    if isinstance(type, basestring):
        return counts[type]()
    for k, v in counts.items():
        if not isinstance(type, list) or k in type:
            rv[k] = v()
    return rv