def referee_browse(request, tournament_id = None, format='html'): logging.info("Tournament: %s", tournament_id) tournament = api.tournament_get(tournament_id = tournament_id) all_referees = api.referees_browse(tournament_id = tournament_id, stat = True) area = 'referee' if format == 'html': return api.response_get(request, locals(), 'referee/templates/browse.html')
def match_create(request, format='html'): if request.POST and request.is_owner: item = api.match_create(request) item = request.POST["league_id"] return http.HttpResponseRedirect("/league/" + str(item) + "/") league_id = request.REQUEST.get('league_id', '') playoffnode_id = request.REQUEST.get('playoffnode_id', '') group_id = request.REQUEST.get('group_id', '') league = api.league_get(league_id = league_id) tournament = league.tournament_id tournament_id = tournament.id all_teams = api.team_browse(league_id = league_id, is_reload = True) #all_teams = api.team_browse(tournament_id = tournament_id)#, is_reload = True) if playoffnode_id: playoff_teams = api.playoff_get_nodeteams(playoffnode_id = playoffnode_id) all_teams = api.team_browse(tournament_id = tournament_id)#, is_reload = True) all_referees = api.referees_browse(tournament_id = tournament_id) # FIXME: new create area = 'match' c = template.RequestContext(request, locals()) #if format == 'html': # t = loader.get_template('match/templates/create.html') # return http.HttpResponse(t.render(c)) if format == 'html': return api.response_get(request, locals(), 'match/templates/create.html')
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')