def post(self): user = users.get_current_user() coach = Coach.all().filter("user ="******"tournament_key")) memberships = [m for m in TournamentMembership.all().ancestor(tournament) if m.team.coach.key() == coach.key()] membership = memberships[0] membership.delete() views.Tournaments.clear()
def post(self): user = users.get_current_user() coach = Coach.all().filter("user ="******"tournament_key")) memberships = [ m for m in TournamentMembership.all().ancestor(tournament) if m.team.coach.key() == coach.key() ] membership = memberships[0] membership.delete() views.Tournaments.clear()
def get(self): # check for a cached version #--------------------------------------------------------------------# if self.emit(self.response.out): return # not cached or evicted from cache; regenerate #--------------------------------------------------------------------# user = users.get_current_user() coach = None if user: coach = Coach.all().filter("user ="******"<img src='get_trophy?size=thumb&tournament_key=%s' />" % tournament.key() return "" def name_getter(tournament): return "<a rel='tournaments' href='%s'>%s</a>" % ( tournament.get_box_href(), tournament.key().name()) def date_getter(tournament): return tournament.created.date() def organizer_getter(tournament): return tournament.owner.key().name() def enrollment_getter(tournament): return "%s/%s" % ( TournamentMembership.all().ancestor(tournament).count(), tournament.max_enrollment) def final_enrollment_getter(tournament): return TournamentMembership.all().ancestor(tournament).count() def winner_getter(tournament): return "<a rel='winners' href='%s'>%s</a> (%s)" % ( tournament.winning_team.get_box_href(), tournament.winning_team.key().name(), tournament.winning_team.coach.key().name()) def tv_getter(tournament): if tournament.min_tv and tournament.max_tv: return "%s - %s" % (tournament.min_tv, tournament.max_tv) elif tournament.min_tv: return "≥ %s" % tournament.min_tv elif tournament.max_tv: return "≤ %s" % tournament.max_tv else: return "Any" def ma_getter(tournament): if tournament.min_ma != None and tournament.max_ma != None: return "%s - %s" % (tournament.min_ma, tournament.max_ma) elif tournament.min_ma != None: return "≥ %s" % tournament.min_ma elif tournament.max_ma != None: return "≤ %s" % tournament.max_ma else: return "Any" def races_getter(tournament): if tournament.races_allowed: return "Restricted" else: return "Any" tournaments = {} for tournament in Tournament.all(): if tournament.winning_team: tournaments.setdefault("Completed", []).append(tournament) elif tournament.started: tournaments.setdefault("In Progress", []).append(tournament) else: tournaments.setdefault("Open", []).append(tournament) tables = [ ("Open", Table( columns = [ Column("", "Trophy Image", trophy_getter, center=True), Column("Name", "Tournament name", name_getter), Column("Created", "Creation date", date_getter), Column("Organizer", "Tournament organizer", organizer_getter), Column("Enrolled", "Enrollment count", enrollment_getter), Column("TV", "TV range", tv_getter), Column("Matches Played", "Matches played range", ma_getter), Column("Races", "Races allowed", races_getter), Column("Seed By", "Teams are seeded by", attrgetter("seed_by")), ], query = tournaments.get("Open", []), cls = "tablesorter tournaments_table", )), ("In Progress", Table( columns = [ Column("", "Trophy Image", trophy_getter, center=True), Column("Name", "Tournament name", name_getter), Column("Created", "Creation date", date_getter), Column("Organizer", "Tournament organizer", organizer_getter), Column("Enrolled", "Final enrollment count", final_enrollment_getter), Column("TV", "TV range", tv_getter), Column("Races", "Races allowed", races_getter), ], query = tournaments.get("In Progress", []), cls = "tablesorter tournaments_table", )), ("Completed", Table( columns = [ Column("", "Trophy Image", trophy_getter, center=True), Column("Name", "Tournament name", name_getter), Column("Created", "Creation date", date_getter), Column("Organizer", "Tournament organizer", organizer_getter), Column("Winner", "Tournament winner", winner_getter), Column("Enrolled", "Final enrollment count", final_enrollment_getter), Column("TV", "TV range", tv_getter), Column("Races", "Races allowed", races_getter), ], query = tournaments.get("Completed", []), cls = "tablesorter tournaments_table", ))] # render and update #--------------------------------------------------------------------# tournaments = misc.render('tournaments.html', locals()) self.update(tournaments) self.response.out.write(tournaments)
def get(self): user = users.get_current_user() if user: log_out_url = users.create_logout_url("/") coach = Coach.all().filter("user ="******"<img src='http://www.oldworldfootball.com/%s'/>" % (match.teamAlogo) return html def logoB_getter(match): html = "<img src='http://www.oldworldfootball.com/%s'/>" % (match.teamBlogo) return html def nameA_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s - %s)" % (match.teamA, match.teamAcoach, match.teamArace) return html def nameB_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s - %s)" % (match.teamB, match.teamBcoach, match.teamBrace) return html def key_name_getter(prediction): return prediction.key().name() def choice_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) #html = "<img src='./get_wager_pic?keyname=%s&team=A'/>" % (prediction.key().name()) html = "<img src='http://www.oldworldfootball.com/%s'/>" % (match.teamAlogo) if not match.gamePlayed: html += "<input type='radio' name='%schoice' value='-1' %s>" % (match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' %s>" % (match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' %s>" % (match.key().name(), prediction.isChecked(1)) else: html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % (match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' disabled %s>" % (match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' disabled %s>" % (match.key().name(), prediction.isChecked(1)) html += "<img src='http://www.oldworldfootball.com/%s'/>" % (match.teamBlogo) #html += "<img src='./get_wager_pic?keyname=%s&team=B'/>" % (prediction.key().name()) return html # Bypassing table.html Django template to create this table # Table requires Jquery code for sortable entires and wagers # Hidden input tags are also used with form. prediction_list = OFL_Prediction.all().filter("season =", season).filter("week =", week).ancestor(coach).filter("gameScored =", False).order("-wager") columns = ["Wager", "Away Team", "Prediction", "Home Team"] table_html = [] table_html.append(''' <table class="ofl_pickem schedule_table"> <thead> <tr>''') for column in columns: table_html.append('<th style="text-align: center;"> %s </th>' % column) table_html.append(''' </tr> </thead> <tbody id="sortable">''') k = 0 for prediction in prediction_list: table_html.append('<tr class="row_%s">' % k) table_html.append('<input type="hidden" name="row_%s" value="%s">' % (k, prediction.key().name())) table_html.append("<input type='hidden' class='row_%s' name='%svalue' value='%s'>" % (k, prediction.key().name(), prediction.wager)) table_html.append('<td class="row_%s" style="text -align: center;">%s</td>' % (k, prediction.wager)) table_html.append('<td style="text-align: center;">%s</td>' % nameA_getter(prediction)) table_html.append('<td style="text-align: center;">%s</td>' % choice_getter(prediction)) table_html.append('<td style="text-align: center;">%s</td>' % nameB_getter(prediction)) k += 1 table_html.append('</tbody>\n</table>') table_html = "\n".join(table_html) played_table = Table( columns = [ # profile Column("Points", "Points Earned", attrgetter("points")), Column("Wager", "Wager Placed", attrgetter("wager")), Column("Away Team", "Away Team", nameA_getter, center=True), Column("Prediction", "Your Prediction", choice_getter, center=True), Column("Home Team", "Home Team", nameB_getter, center=True), ], query = OFL_Prediction.all().filter("season =", season).filter("week =", week).ancestor(coach).filter("gameScored =", True).order("-points"), id = "played_table", cls = "tablesorter", ) def logo_getter(standing): coach = Coach.get_by_key_name(standing.get_coach_name()) img = "<img src='%s' />" % coach.get_logo_url() # FIXME: thumb is broken return "<div style='background-color: %(color)s'>%(img)s</div>" % { 'color': coach.color, 'img': img} def name_getter(standing): coach = Coach.get_by_key_name(standing.get_coach_name()) return "<a class='leader_link' rel='leader_coach' href='%s'>%s</a>" % ( coach.get_box_href(),coach.key().name()) leader_table = {} query = OFLPickemStats.all().order('-all_time').fetch(10) label = "alltime" leader_table[label] = Table( columns = [ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Score", "Score", attrgetter("all_time")), ], query = query, cls = "leader_table", ) query = OFLPickemSeasonRecord.all().filter("season =", season).order("-points").fetch(10) label = "season" leader_table[label] = Table( columns = [ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Score", "Score", attrgetter("points")), ], query = query, cls = "leader_table", ) query = OFLPickemWeekRecord.all().filter("week =", week).filter("season =", season).order("-points").fetch(10) label = "week" leader_table[label] = Table( columns = [ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Score", "Score", attrgetter("points")), ], query = query, cls = "leader_table", ) query = OFLPickemStats.all().order('-matches').fetch(10) label = "alltime_matches" leader_table[label] = Table( columns = [ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Matches", "Matches Predicted", attrgetter("matches")), ], query = query, cls = "leader_table", ) query = OFLPickemSeasonRecord.all().filter("season =", season).order("-matches").fetch(10) label = "season_matches" leader_table[label] = Table( columns = [ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Matches", "Matches Predicted", attrgetter("matches")), ], query = query, cls = "leader_table", ) query = OFLPickemWeekRecord.all().filter("week =", week).filter("season =", season).order("-matches").fetch(10) label = "week_matches" leader_table[label] = Table( columns = [ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Matches", "Matches Predicted", attrgetter("matches")), ], query = query, cls = "leader_table", ) else: log_in_url = users.create_login_url("/") # render and update #--------------------------------------------------------------------# ofl_pickem_page = misc.render('ofl_pickem_page.html', locals()) self.update(ofl_pickem_page) self.response.out.write(ofl_pickem_page)
def get(self): # check for a cached version #--------------------------------------------------------------------# tournament = Tournament.get_by_key_name( self.request.get("tournament_key_name")) if tournament.started: if self.emit(self.response.out, tournament.key()): return # not cached or evicted from cache; regenerate #--------------------------------------------------------------------# teams = [ m.team for m in TournamentMembership.all().ancestor(tournament) ] races_allowed = [] for race_key in tournament.races_allowed: races_allowed.append(Race.get(race_key)) if not tournament.started: user = users.get_current_user() coach = None if user: coach = Coach.all().filter("user ="******":")] # pixel settings width_unit = 530 / round match_width = 200 # compute data for each match_up match_up_data = [] for match_up, child in match_ups: round, seed = [ int(x) for x in match_up.key().name().split(":") ] position_left = round * width_unit team_data = [] for i, mm in enumerate( match_up.tournamentmatchupmembership_set.order( "__key__")): data = {} data["name"] = "_" * 25 data["seed"] = "" data["score"] = "" if mm.membership: team = mm.membership.team if team.matches: data[ "name"] = "<a rel='tournament_teams' href='%s'>%s</a>" % ( team.get_box_href(), team.key().name()) else: data["name"] = "<b title='%s'>%s</b>" % ( team.coach.key().name(), team.key().name()) data["seed"] = mm.membership.seed + 1 if match_up.match: team_record = match_up.match.get_team_records_query( ).filter("team =", mm.membership.team.key()).get() score = str(team_record.tds_for) if (match_up.winner.key() == mm.membership.key() and (team_record.tds_for == team_record.tds_against or match_up.match.disconnect)): score += "*" data["score"] = "<b>%s</b>" % score elif match_up.winner: # if there was a winner but no match then it was a forfeit if match_up.winner.key() == mm.membership.key(): data["score"] = " " else: data["score"] = "<b><i>F</i></b>" team_data.append(data) if child == 0: arrow_class = "down_arrow" elif child == 1: arrow_class = "up_arrow" else: arrow_class = None match_data = match_up.match end_this_match = width_unit * round + match_width mid_next_match = width_unit * (round + 1) + match_width / 2 arrow_width = mid_next_match - end_this_match match_up_data.append((round, team_data, position_left, arrow_width, arrow_class, match_data)) # render and update #--------------------------------------------------------------------# tournament_box = misc.render('tournament_box.html', locals()) if tournament.started: self.update(tournament_box, tournament.key()) self.response.out.write(tournament_box)
def get(self): user = users.get_current_user() if user: log_out_url = users.create_logout_url("/") coach = Coach.all().filter("user ="******"<img src='http://www.oldworldfootball.com/%s'/>" % ( match.teamAlogo) return html def logoB_getter(match): html = "<img src='http://www.oldworldfootball.com/%s'/>" % ( match.teamBlogo) return html def nameA_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s - %s)" % (match.teamA, match.teamAcoach, match.teamArace) return html def nameB_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s - %s)" % (match.teamB, match.teamBcoach, match.teamBrace) return html def key_name_getter(prediction): return prediction.key().name() def choice_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) #html = "<img src='./get_wager_pic?keyname=%s&team=A'/>" % (prediction.key().name()) html = "<img src='http://www.oldworldfootball.com/%s'/>" % ( match.teamAlogo) if not match.gamePlayed: html += "<input type='radio' name='%schoice' value='-1' %s>" % ( match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' %s>" % ( match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' %s>" % ( match.key().name(), prediction.isChecked(1)) else: html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % ( match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' disabled %s>" % ( match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' disabled %s>" % ( match.key().name(), prediction.isChecked(1)) html += "<img src='http://www.oldworldfootball.com/%s'/>" % ( match.teamBlogo) #html += "<img src='./get_wager_pic?keyname=%s&team=B'/>" % (prediction.key().name()) return html # Bypassing table.html Django template to create this table # Table requires Jquery code for sortable entires and wagers # Hidden input tags are also used with form. prediction_list = OFL_Prediction.all().filter( "season =", season).filter("week =", week).ancestor(coach).filter( "gameScored =", False).order("-wager") columns = ["Wager", "Away Team", "Prediction", "Home Team"] table_html = [] table_html.append(''' <table class="ofl_pickem schedule_table"> <thead> <tr>''') for column in columns: table_html.append( '<th style="text-align: center;"> %s </th>' % column) table_html.append(''' </tr> </thead> <tbody id="sortable">''') k = 0 for prediction in prediction_list: table_html.append('<tr class="row_%s">' % k) table_html.append( '<input type="hidden" name="row_%s" value="%s">' % (k, prediction.key().name())) table_html.append( "<input type='hidden' class='row_%s' name='%svalue' value='%s'>" % (k, prediction.key().name(), prediction.wager)) table_html.append( '<td class="row_%s" style="text -align: center;">%s</td>' % (k, prediction.wager)) table_html.append( '<td style="text-align: center;">%s</td>' % nameA_getter(prediction)) table_html.append( '<td style="text-align: center;">%s</td>' % choice_getter(prediction)) table_html.append( '<td style="text-align: center;">%s</td>' % nameB_getter(prediction)) k += 1 table_html.append('</tbody>\n</table>') table_html = "\n".join(table_html) played_table = Table( columns=[ # profile Column("Points", "Points Earned", attrgetter("points")), Column("Wager", "Wager Placed", attrgetter("wager")), Column("Away Team", "Away Team", nameA_getter, center=True), Column("Prediction", "Your Prediction", choice_getter, center=True), Column("Home Team", "Home Team", nameB_getter, center=True), ], query=OFL_Prediction.all().filter( "season =", season).filter("week =", week).ancestor(coach).filter( "gameScored =", True).order("-points"), id="played_table", cls="tablesorter", ) def logo_getter(standing): coach = Coach.get_by_key_name(standing.get_coach_name()) img = "<img src='%s' />" % coach.get_logo_url( ) # FIXME: thumb is broken return "<div style='background-color: %(color)s'>%(img)s</div>" % { 'color': coach.color, 'img': img } def name_getter(standing): coach = Coach.get_by_key_name(standing.get_coach_name()) return "<a class='leader_link' rel='leader_coach' href='%s'>%s</a>" % ( coach.get_box_href(), coach.key().name()) leader_table = {} query = OFLPickemStats.all().order('-all_time').fetch(10) label = "alltime" leader_table[label] = Table( columns=[ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Score", "Score", attrgetter("all_time")), ], query=query, cls="leader_table", ) query = OFLPickemSeasonRecord.all().filter( "season =", season).order("-points").fetch(10) label = "season" leader_table[label] = Table( columns=[ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Score", "Score", attrgetter("points")), ], query=query, cls="leader_table", ) query = OFLPickemWeekRecord.all().filter("week =", week).filter( "season =", season).order("-points").fetch(10) label = "week" leader_table[label] = Table( columns=[ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Score", "Score", attrgetter("points")), ], query=query, cls="leader_table", ) query = OFLPickemStats.all().order('-matches').fetch(10) label = "alltime_matches" leader_table[label] = Table( columns=[ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Matches", "Matches Predicted", attrgetter("matches")), ], query=query, cls="leader_table", ) query = OFLPickemSeasonRecord.all().filter( "season =", season).order("-matches").fetch(10) label = "season_matches" leader_table[label] = Table( columns=[ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Matches", "Matches Predicted", attrgetter("matches")), ], query=query, cls="leader_table", ) query = OFLPickemWeekRecord.all().filter("week =", week).filter( "season =", season).order("-matches").fetch(10) label = "week_matches" leader_table[label] = Table( columns=[ Column(" ", "Logo", logo_getter, center=True), Column("Coach Name", "Coach name", name_getter), Column("Matches", "Matches Predicted", attrgetter("matches")), ], query=query, cls="leader_table", ) else: log_in_url = users.create_login_url("/") # render and update #--------------------------------------------------------------------# ofl_pickem_page = misc.render('ofl_pickem_page.html', locals()) self.update(ofl_pickem_page) self.response.out.write(ofl_pickem_page)
def get(self): user = users.get_current_user() if user: log_out_url = users.create_logout_url("/") coach = Coach.all().filter("user ="******"schedule").split("-") if not season or not week: season, week = misc.get_ofl_season_and_week() season += 3 else: season = int(season) week = int(week) parser = OFLScheduleParser() ofl_info = urlfetch.fetch( "http://www.shalkith.com/bloodbowl/processSchedule.php?s=%s&w=%s" % (season, week)) parser.feed(ofl_info.content) update_schedule_entries(coach, season, week, parser.data) sort_wagers(coach, season, week) def logoA_getter(match): html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % ( match.teamAlogo) return html def logoB_getter(match): html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % ( match.teamBlogo) return html def nameA_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s)" % (match.teamA, match.teamAcoach) return html def nameB_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s)" % (match.teamB, match.teamBcoach) return html def key_name_getter(prediction): return prediction.key().name() def choice_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % ( match.teamAlogo) if not match.gamePlayed: html += "<input type='radio' name='%schoice' value='-1' %s>" % ( match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' %s>" % ( match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' %s>" % ( match.key().name(), prediction.isChecked(1)) else: html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % ( match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' disabled %s>" % ( match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' disabled %s>" % ( match.key().name(), prediction.isChecked(1)) html += "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % ( match.teamBlogo) return html # Bypassing table.html Django template to create this table # Table requires Jquery code for sortable entires and wagers # Hidden input tags are also used with form. prediction_list = OFL_Prediction.all().filter( "season =", season).filter("week =", week).ancestor(coach).filter( "gameScored =", False).order("-wager") columns = ["Wager", "Away Team", "Prediction", "Home Team"] table_html = [] table_html.append(''' <table class="ofl_pickem schedule_table"> <thead> <tr>''') for column in columns: table_html.append( '<th style="text-align: center;"> %s </th>' % column) table_html.append(''' </tr> </thead> <tbody id="sortable">''') k = 0 for prediction in prediction_list: table_html.append('<tr class="row_%s">' % k) table_html.append( '<input type="hidden" name="row_%s" value="%s">' % (k, prediction.key().name())) table_html.append( "<input type='hidden' class='row_%s' name='%svalue' value='%s'>" % (k, prediction.key().name(), prediction.wager)) table_html.append( '<td class="row_%s" style="text -align: center;">%s</td>' % (k, prediction.wager)) table_html.append( '<td style="text-align: center;">%s</td>' % nameA_getter(prediction)) table_html.append( '<td style="text-align: center;">%s</td>' % choice_getter(prediction)) table_html.append( '<td style="text-align: center;">%s</td>' % nameB_getter(prediction)) k += 1 table_html.append('</tbody>\n</table>') table_html = "\n".join(table_html) played_table = Table( columns=[ # profile Column("Points", "Points Earned", attrgetter("points")), Column("Wager", "Wager Placed", attrgetter("wager")), Column("Away Team", "Away Team", nameA_getter, center=True), Column("Prediction", "Your Prediction", choice_getter, center=True), Column("Home Team", "Home Team", nameB_getter, center=True), ], query=OFL_Prediction.all().filter( "season =", season).filter("week =", week).ancestor(coach).filter( "gameScored =", True).order("-points"), id="played_table", cls="tablesorter", ) else: log_in_url = users.create_login_url("/") # render and update #--------------------------------------------------------------------# ofl_pickem_page = misc.render('ofl_pickem_box.html', locals()) self.update(ofl_pickem_page) self.response.out.write(ofl_pickem_page)
def get(self): user = users.get_current_user() if user: log_out_url = users.create_logout_url("/") coach = Coach.all().filter("user ="******"schedule").split("-") if not season or not week: season, week = misc.get_ofl_season_and_week() season += 3 else: season = int(season) week = int(week) parser = OFLScheduleParser() ofl_info = urlfetch.fetch("http://www.shalkith.com/bloodbowl/processSchedule.php?s=%s&w=%s" % (season, week)) parser.feed(ofl_info.content) update_schedule_entries(coach, season, week, parser.data) sort_wagers(coach, season, week) def logoA_getter(match): html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (match.teamAlogo) return html def logoB_getter(match): html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (match.teamBlogo) return html def nameA_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s)" % (match.teamA, match.teamAcoach) return html def nameB_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "%s (%s)" % (match.teamB, match.teamBcoach) return html def key_name_getter(prediction): return prediction.key().name() def choice_getter(prediction): match = OFL_Match.get_by_key_name(prediction.key().name()) html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (match.teamAlogo) if not match.gamePlayed: html += "<input type='radio' name='%schoice' value='-1' %s>" % (match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' %s>" % (match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' %s>" % (match.key().name(), prediction.isChecked(1)) else: html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % (match.key().name(), prediction.isChecked(-1)) html += "<input type='radio' name='%schoice' value='0' disabled %s>" % (match.key().name(), prediction.isChecked(0)) html += "<input type='radio' name='%schoice' value='1' disabled %s>" % (match.key().name(), prediction.isChecked(1)) html += "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (match.teamBlogo) return html # Bypassing table.html Django template to create this table # Table requires Jquery code for sortable entires and wagers # Hidden input tags are also used with form. prediction_list = OFL_Prediction.all().filter("season =", season).filter("week =", week).ancestor(coach).filter("gameScored =", False).order("-wager") columns = ["Wager", "Away Team", "Prediction", "Home Team"] table_html = [] table_html.append(''' <table class="ofl_pickem schedule_table"> <thead> <tr>''') for column in columns: table_html.append('<th style="text-align: center;"> %s </th>' % column) table_html.append(''' </tr> </thead> <tbody id="sortable">''') k = 0 for prediction in prediction_list: table_html.append('<tr class="row_%s">' % k) table_html.append('<input type="hidden" name="row_%s" value="%s">' % (k, prediction.key().name())) table_html.append("<input type='hidden' class='row_%s' name='%svalue' value='%s'>" % (k, prediction.key().name(), prediction.wager)) table_html.append('<td class="row_%s" style="text -align: center;">%s</td>' % (k, prediction.wager)) table_html.append('<td style="text-align: center;">%s</td>' % nameA_getter(prediction)) table_html.append('<td style="text-align: center;">%s</td>' % choice_getter(prediction)) table_html.append('<td style="text-align: center;">%s</td>' % nameB_getter(prediction)) k += 1 table_html.append('</tbody>\n</table>') table_html = "\n".join(table_html) played_table = Table( columns = [ # profile Column("Points", "Points Earned", attrgetter("points")), Column("Wager", "Wager Placed", attrgetter("wager")), Column("Away Team", "Away Team", nameA_getter, center=True), Column("Prediction", "Your Prediction", choice_getter, center=True), Column("Home Team", "Home Team", nameB_getter, center=True), ], query = OFL_Prediction.all().filter("season =", season).filter("week =", week).ancestor(coach).filter("gameScored =", True).order("-points"), id = "played_table", cls = "tablesorter", ) else: log_in_url = users.create_login_url("/") # render and update #--------------------------------------------------------------------# ofl_pickem_page = misc.render('ofl_pickem_box.html', locals()) self.update(ofl_pickem_page) self.response.out.write(ofl_pickem_page)