def match_print(request, match_id = None, format='html'): match = api.match_get(match_id = match_id) if not match: raise Http404 team0 = api.team_get(team_id = match["teams"][0]["id"]) team1 = api.team_get(team_id = match["teams"][1]["id"]) league = match["league_id"] league_id = league["id"] tournament = match["tournament_id"] tournament_id = tournament["id"] team0_players_active = api.team_get_players_active(team_id = match["teams"][0]["id"]) team1_players_active = api.team_get_players_active(team_id = match["teams"][1]["id"]) #all_groups = api.group_browse(league_id = league_id) area = 'match' c = template.RequestContext(request, locals()) # TODO(tyler): Other output formats. if format == 'html': t = loader.get_template('match/templates/print.html') return http.HttpResponse(t.render(c))
def match_item(request, match_id = None, format='html'): match = api.match_get(match_id = match_id) if not match: raise Http404 team0 = api.team_get(team_id = match["teams"][0]["id"], is_reload = True) team1 = api.team_get(team_id = match["teams"][1]["id"], is_reload = True) league = match["league_id"] league_id = league["id"] tournament = match["tournament_id"] tournament_id = tournament["id"] area = 'match' if not request.is_owner: return api.response_get(request, locals(), 'match/templates/item.html') if request.method == "POST" and request.is_owner: #for i,v in request.POST.items(): # logging.info("i: %s", i) # logging.info("v: %s", v) raw_post_data = request.read() taskqueue.add(url='/match/complete/', method = 'POST', params={ 'post_data': raw_post_data }) return http.HttpResponseRedirect("/league/" + str(league_id) + "/") if request.method == "GET" and request.is_owner: is_edit_match = True #all_teams = api.team_browse(league_id = league_id) all_teams = api.team_browse(tournament_id = tournament_id) all_referees = api.referees_browse(tournament_id = tournament_id) team0_players_active = api.team_get_players_active(team_id = match["teams"][0]["id"]) team1_players_active = api.team_get_players_active(team_id = match["teams"][1]["id"]) for match_item in match["teams"][0]["players"]: for item in team0_players_active: if item["id"] == match_item["id"]: team0_players_active.remove(item) for match_item in match["teams"][1]["players"]: for item in team1_players_active: if item["id"] == match_item["id"]: team1_players_active.remove(item) # %Y-%m-%d %H:%M:%S # data = str(datetime.datetime.now()) logging.info("Data: %s", match["datetime"]) if format == 'html': return api.response_get(request, locals(), 'match/templates/edit.html')