コード例 #1
0
ファイル: views.py プロジェクト: uve/onarena
def team_create(request, format='html'):

    league_id = request.REQUEST.get('league_id', '')    
    league = api.league_get(league_id = league_id) 
    
    group_id = request.REQUEST.get('group_id', '')
     
        
    
    if request.POST and request.is_owner:
        item = api.team_create(request)
        return http.HttpResponseRedirect("/league/" + league_id + "/")
    
    
    all_teams = api.team_browse(tournament_id = request.tournament.id)   
    
    '''    
    owned_leagues = []
    owned_tournaments = request.user.user_tournaments
    for c in owned_tournaments:
        for c2 in c.tournament_leagues:
            owned_leagues.append(c2)
    '''
            
    area = 'team'

    
    #c = template.RequestContext(request, locals())
    #if format == 'html':
    #    t = loader.get_template('team/templates/create.html')
    #    return http.HttpResponse(t.render(c))
    
    if format == 'html':
        return api.response_get(request, locals(), 'team/templates/create.html')     
コード例 #2
0
ファイル: views.py プロジェクト: uve/onarena
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') 
コード例 #3
0
ファイル: views.py プロジェクト: 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')     
コード例 #4
0
ファイル: views.py プロジェクト: uve/onarena
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')