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 team_item(request, team_id = None, format='html'): area = 'team' load_async = 'team_item' if format == 'html': team = api.team_get(team_id = team_id, is_reload=True) if not team: raise Http404 all_players = api.team_get_players(team_id = team_id, stat = True) #all_matches = api.match_browse(team_id = team_id) return api.response_get(request, locals(), 'team/templates/item.html') if format == 'json': jsoncallback = request.REQUEST.get("jsoncallback") limit = request.REQUEST.get("limit") logging.info("CALLBACK: %s", jsoncallback) all_players = api.team_get_players(team_id = team_id) c = template.RequestContext(request, locals()) t = loader.get_template('team/templates/item.json') return util.HttpJsonResponse(t.render(c), request)
def player_edit(request,player_id=None, format='html'): team_id = request.REQUEST.get('team_id', '') if team_id: team = api.team_get(team_id = team_id) player = api.player_get(player_id = player_id, team_id = team_id) else: player = api.player_get(player_id = player_id) team_id = None if not player: return http.HttpResponse() logging.info("player: %s", player) #logging.info("player: %s", player["tournament_id"]["sport_id"]["id"]) if not request.is_owner: return http.HttpResponseRedirect("/player/" + player_id + "/") all_positions = api.positions_browse(sport_id = player["tournament_id"]["sport_id"]["id"]) if request.POST and request.is_owner: item = api.player_edit(request = request, player_id = player_id) return http.HttpResponseRedirect("/player/" + player_id + "/") area = 'player' if format == 'html': return api.response_get(request, locals(), 'player/templates/edit.html')
def team_edit(request, team_id = None, format='html'): team = api.team_get(team_id = team_id) if not team: return http.HttpResponse() if not request.is_owner: return http.HttpResponseRedirect("/team/" + team_id + "/") if request.method == 'POST': form = models.TeamForm(request.POST) if form.is_valid(): item = api.team_edit(form = form, team_id = team_id) return http.HttpResponseRedirect("/team/" + team_id + "/") else: form = models.TeamForm(team) # An unbound form area = 'team' if format == 'html': return api.response_get(request, locals(), 'team/templates/edit.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')