Example #1
0
def upcoming_matches(context):
    if 'formset' in context:
        formset = context['formset']
    else:
        formset = UpcomingMatchesFromset(
            queryset=Match.ready_group_matches() | Match.ready_bracket_matches() | Match.ready_doubles_matches())
    context.update({
        'formset': formset,
        'matches': chain(Match.ready_group_matches(),
                                   Match.ready_bracket_matches(),
                                   Match.ready_doubles_matches())
    })
    return context
Example #2
0
def upcoming_matches(request):
    response_data = []
    response_data.extend([
        dict(id=match.id,
             type='Group',
             group=unicode(match.group))
        for match in Match.ready_group_matches()
    ])
    response_data.extend([
        dict(id=match.id,
             type='Bracket',
             player1=unicode(match.player1),
             player2=unicode(match.player2))
        for match in Match.ready_bracket_matches()
    ])
    response_data.extend([
        dict(id=match.id,
             type='Double',
             player1=unicode(match.player1),
             player2=unicode(match.player2))
        for match in Match.ready_doubles_matches()
    ])
    return HttpResponse(json.dumps(response_data),
                        content_type="application/json")
Example #3
0
 def test_ready_bracket_matches_is_efficient(self):
     with self.assertNumQueries(1):
         bracket_matches = Match.ready_bracket_matches()
         for match in bracket_matches:
             match.description()