Esempio n. 1
0
def approve_all(request):
    # This view approves all the videos on the current page.
    site_settings = SiteSettings.objects.get_current()

    video_paginator = get_video_paginator(site_settings)
    try:
        page = video_paginator.page(int(request.GET.get('page', 1)))
    except Exception:
        # let the other view handle it
        return _approve_all(request)

    tier = get_object_or_404(Tier, sitetierinfo__site=settings.SITE_ID)
    if tier.video_limit is not None:
        videos = Video.objects.filter(status=Video.ACTIVE,
                                      site=settings.SITE_ID)
        remaining = tier.video_limit - videos.count()
        need = len(page.object_list)

        if need > remaining:
            return HttpResponse(content=_video_limit_error(need, remaining,
                                                           tier.video_limit),
                                status=402)

    return _approve_all(request)
def approve_all(request):
    tier_info = TierInfo.objects.get_current()

    video_paginator = get_video_paginator(tier_info.site_settings)
    try:
        page = video_paginator.page(int(request.GET.get('page', 1)))
    except Exception:
        # let the other view handle it
        return _approve_all(request)

    if tier_info.enforce_tiers():
        tier_remaining_videos = tier_info.get_tier().remaining_videos()
        if len(page.object_list) > tier_remaining_videos:
            remaining = tier_remaining_videos
            need = len(page.object_list)
            return HttpResponse(content=(
                    "You are trying to approve %(need)i videos at a time. "
                    "However, you can approve only %(remaining)i more videos "
                    "under your video limit. Please upgrade your account to "
                    "increase your limit, or unapprove some older videos to "
                    "make space for newer ones.") % {
                    'need': need,
                    'remaining': remaining},
                                status=402)