Skip to content

Commit

Permalink
Merge pull request #53 from usgo/Issue20
Browse files Browse the repository at this point in the history
Addressing Issue #20 for tournament detail page.
  • Loading branch information
Michael Hiiva authored Jul 15, 2019
2 parents c628e64 + 4d4a13b commit afe6910
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
21 changes: 21 additions & 0 deletions agagd/agagd_core/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def render(self, value, record, bound_column):
self.attrs['td'] = {'class': 'foo'}
return tables.LinkColumn.render(self, value, record, bound_column)

#Standard gameTable display as is on agagd.usgo.org and most pages
class GameTable(tables.Table):
pin_player_1 = WinnerColumn('W',
viewname='agagd_core.views.member_detail',
Expand All @@ -35,6 +36,26 @@ class Meta:
"pin_player_2", 'handicap', 'komi', 'tournament_code')
sequence = fields

#Modified gaeTable to remove duplicate tournament listing displayed on the page, GitHubIssue#20
class GameTable2(tables.Table):
pin_player_1 = WinnerColumn('W',
viewname='agagd_core.views.member_detail',
verbose_name="white player",
kwargs={"member_id":tables.A('pin_player_1.member_id')})
pin_player_2 = WinnerColumn('B',
'agagd_core.views.member_detail',
verbose_name="black player",
kwargs={"member_id":tables.A('pin_player_2.member_id')})
class Meta:
model = Game
# add class="paleblue" to <table> tag
attrs = {"class": "paleblue"}
fields = ("game_date", "round", "pin_player_1",
"pin_player_2", 'handicap', 'komi')
sequence = fields



class OpponentTable(tables.Table):
def __init__(self, qs, p1, *args, **kwargs):
self.this_player = p1
Expand Down
8 changes: 4 additions & 4 deletions agagd/agagd_core/views/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from agagd_core.json_response import JsonResponse
from agagd_core.models import Game, Member, Tournament, Chapters, Country
from agagd_core.tables import GameTable, MemberTable, TournamentTable, OpponentTable, TournamentPlayedTable
from agagd_core.tables import GameTable, GameTable2, MemberTable, TournamentTable, OpponentTable, TournamentPlayedTable
from datetime import datetime, timedelta, date
from django.core import exceptions
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -163,11 +163,11 @@ def member_vs(request, member_id, other_id):

def tournament_detail(request, tourn_code):
tourney = Tournament.objects.get(pk=tourn_code)
game_table = GameTable(tourney.games_in_tourney.all())
RequestConfig(request, paginate={'per_page': 20}).configure(game_table)
game_table2 = GameTable2(tourney.games_in_tourney.all())
RequestConfig(request, paginate={'per_page': 20}).configure(game_table2)
return render(request, 'agagd_core/tourney.html',
{
'game_table': game_table,
'game_table2': game_table2,
'tournament': tourney,
})

Expand Down
2 changes: 1 addition & 1 deletion agagd/templates/agagd_core/tourney.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ <h3> Recreated Wall List </h3>
<pre> {{ tournament.wall_list }} </pre>

<h3> Games </h3>
{% render_table game_table %}
{% render_table game_table2 %}

{% endblock %}

0 comments on commit afe6910

Please sign in to comment.