Esempio n. 1
0
File: views.py Progetto: uve/onarena
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')     
Esempio n. 2
0
File: views.py Progetto: uve/onarena
def player_create(request, team_id = None, format='html'):

    load_async = 'player_create'   
    
    if not team_id:
        team_id = request.REQUEST.get('team_id', '')
        
        
    if not team_id:
        return http.HttpResponse()       
    #team = api.team_get(team_id = team_id)     
    #tournament_id = team["tournament_id"]["id"]
    #sport_id = team["tournament_id"]["sport_id"]["id"]

    
    return_url = request.REQUEST.get('return_url', '')
    
    if request.method == "POST" and request.is_owner:   
        item = api.player_create(request = request)
        
        if return_url:
            return http.HttpResponseRedirect(return_url)
            
        return http.HttpResponseRedirect("/team/" + team_id + "/")


    team = models.Team.get_item(team_id)
    if not team:
        return None   
   
    tournament    = team.tournament_id
    tournament_id = team.tournament_id.id        
    sport_id      = team.tournament_id.sport_id.id

    all_positions = api.positions_browse(sport_id = sport_id)
    all_teams = api.team_browse(tournament_id = tournament_id)
    
    area = 'player'
    
    if format == 'html':
        return api.response_get(request, locals(), 'player/templates/create.html')