From a38f15945edc8825086c8a426d7f6e81bece496f Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 29 May 2012 00:02:30 -0400 Subject: [PATCH] some cleanup & order by match__id --- fowl/game/models.py | 3 +-- fowl/game/views.py | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fowl/game/models.py b/fowl/game/models.py index 90f6ef6..e261cc8 100644 --- a/fowl/game/models.py +++ b/fowl/game/models.py @@ -81,8 +81,7 @@ class Event(models.Model): match = Match.objects.create(event=self, title_at_stake=title_at_stake, - notes=notes - ) + notes=notes) for team in teams: mt = MatchTeam.objects.create(match=match) if not isinstance(team, (list, tuple)): diff --git a/fowl/game/views.py b/fowl/game/views.py index 977278d..eb1bf75 100644 --- a/fowl/game/views.py +++ b/fowl/game/views.py @@ -10,19 +10,20 @@ def events(request, league_id): leagues = League.objects.all() events = {} points = TeamPoints.objects.filter(team__league_id=league_id).order_by( - 'match', 'team').select_related() + 'match__id', 'team').select_related() for tp in points: event_id = tp.match.event_id if event_id not in events: events[event_id] = tp.match.event events[event_id].scores = {} events[event_id].match_list = {} - events[event_id].match_list.setdefault(tp.match, [] - ).append(tp) + events[event_id].match_list.setdefault(tp.match, []).append(tp) events[event_id].scores.setdefault(tp.team, 0) events[event_id].scores[tp.team] += tp.points events = sorted(events.values(), key=lambda x: x.date, reverse=True) - return render(request, "events.html", {'events': events, 'view': 'events', 'league': league, 'leagues':leagues}) + return render(request, "events.html", + {'events': events, 'view': 'events', 'league': league, + 'leagues':leagues}) def edit_event(request, event):