Permalink
Browse files

Display of new ordering scheme

FinishedGame.winner is now always a list, so
we should always talk "winners", not "winner".
  • Loading branch information...
1 parent acfee89 commit cd6943f55840c67e2a4d72d37da5e770bfcbd9e4 Torbjørn Thorsen committed Jan 9, 2012
@@ -47,11 +47,21 @@
</ul>
</dd>
- <dt>Winner</dt>
+ <dt>Winners</dt>
<dd>
- {% game_winner game winner %}
- {% if winner %}
- <a href="{% url "golfstats-players-players-detail" winner.player.id %}">{{ winner.player }}</a> ({{ winner.score_display }}, {{ winner.throws }} throws)
+ {% game_winners game winners %}
+ {% if winners %}
+ <ul>
+ {% for winner in winners %}
+ <li>
+ <a
+ href="{% url "golfstats-players-players-detail" winner.player.id %}">
+ {{ winner.player }}
+ </a>
+ ({{ winner.score_display }}, {{ winner.throws }} throws)
+ </li>
+ {% endfor %}
+ </ul>
{% else %}
Nobody
{% endif %}
@@ -21,7 +21,7 @@
<th>Date</th>
<th>Course</th>
<th>State</th>
- <th>Winner</th>
+ <th>Winners</th>
<th>Players</th>
</tr>
</thead>
@@ -33,9 +33,18 @@
<td><a href="{% url "golfstats-courses-course-detail" game.course.id %}">{{ game.course }}</a></td>
<td>{{ game.get_state_display }}</td>
<td>
- {% game_winner game winner %}
- {% if winner %}
- <a href="{% url "golfstats-players-players-detail" winner.player.id %}">{{ winner.player }}</a>
+ {% game_winners game winners %}
+ {% if winners %}
+ <ul>
+ {% for winner in winners %}
+ <li>
+ <a
+ href="{% url "golfstats-players-players-detail" winner.player.id %}">
+ {{ winner.player }}
+ </a>
+ </li>
+ {% endfor %}
+ </ul>
{% else %}
Nobody
{% endif %}
@@ -2,7 +2,7 @@
from django.template import Variable
from django.template.base import VariableDoesNotExist
-from games.models import FinishedGamePlayer
+from games.models import FinishedGamePlayer, FinishedGame
register = template.base.Library()
@@ -65,7 +65,7 @@ def render(self, context):
@register.tag
-def game_winner(parser, token):
+def game_winners(parser, token):
try:
tag_name, game, context_name = token.split_contents()
@@ -74,23 +74,22 @@ def game_winner(parser, token):
"%r tag requires two arguments" %
token.contents.split()[0])
- return GameWinnerNode(game, context_name)
+ return GameWinnersNode(game, context_name)
-class GameWinnerNode(template.Node):
+class GameWinnersNode(template.Node):
def __init__(self, game, context_name):
self.game = Variable(game)
self.context_name = context_name
def render(self, context):
- super(GameWinnerNode, self).render(context)
+ super(GameWinnersNode, self).render(context)
game = self.game.resolve(context)
try:
context[self.context_name] = \
- game.finishedgameplayer_set.filter(
- order=0)[0]
- except IndexError:
+ game.finishedgame.winners
+ except FinishedGame.DoesNotExist:
context[self.context_name] = ''
return ''

0 comments on commit cd6943f

Please sign in to comment.