Пример #1
0
def results_index_view(request):
    context = globalContext(request)
    queryset = past_contests_queryset().annotate(count=Sum('votes__counter')).all()
    now = datetime.datetime.now()
    total_votes = contest_models.Vote.objects.filter(contest__end__lte=now).values('contest_id').annotate(total_votes=Sum('counter')).order_by('-contest__end')
    contests = [(contest, best_single_cards(contest), total_votes['total_votes']) for contest, total_votes in zip(queryset, total_votes)]
    context.update({
        'contests': contests,
        'title': 'Contests listing',
        'current': 'past_contests',
    })
    return render(request, 'contest_result_index.html', context)
Пример #2
0
def results_index_view(request):
    context = globalContext(request)
    if settings.HIGH_TRAFFIC:
        return render(request, 'disabled.html', context)
    queryset = past_contests_queryset().annotate(count=Sum('votes__counter')).select_related('suggested_by', 'image_by')
    now = datetime.datetime.now()
    total_votes = contest_models.Vote.objects.filter(contest__end__lte=now).values('contest_id').annotate(total_votes=Sum('counter')).order_by('-contest__end')
    contests = [(contest, best_single_cards(contest), total_votes['total_votes']) for contest, total_votes in zip(queryset, total_votes)]
    context.update({
        'contests': contests,
        'current': 'past_contests',
    })
    return render(request, 'contest_result_index.html', context)