Example #1
0
def widget(request, format="html"):

    # logging.info("request: %s",request)
    all_groups = api.group_browse(league_id="1001")

    if format == "html":
        return api.response_get(request, locals(), "common/templates/widget.html")
Example #2
0
File: views.py Project: uve/onarena
def tournament_create(request, format='html'):  
        
        
    if request.method == 'POST':
        form = models.TournamentFormCreate(request.POST)
        if form.is_valid():             
            item = api.tournament_create(request = request, form = form)
            if item:
               return http.HttpResponseRedirect("/tournament/" + str(item) + "/")
            logging.info("Form is invalid")         
        else:
            logging.info("Form is invalid")            
    
    #form = models.TournamentForm() # An unbound form
    all_sports = api.sport_browse(limit = 1000)
    
    #logging.info("hes: %s", all_sports)
    
    try:
        lat, lon = request.META["HTTP_X_APPENGINE_CITYLATLONG"].split(",")
    except:
        lat, lon = ("", "")
    
    logging.info("lat: %s", lat)
    logging.info("lon: %s", lon)
    

    area = 'create'    
    is_map = True    
    
    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/create.html') 
Example #3
0
File: views.py Project: uve/onarena
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)
Example #4
0
File: views.py Project: uve/onarena
def tournament_create_step1(request, format='html'):  

    return api.response_get(request, locals(), 'tournament/templates/create_step1.html') 
        
    if request.method == 'POST':
        form = models.TournamentFormStep1(request.POST)
        
        sport_id = request.POST.get("sport","")            
        sport = models.Sport.get_item(sport_id)
        
        if form.is_valid() and sport:             
            return api.response_get(request, locals(), 'tournament/templates/create_step1.html') 
        else:
            logging.info("Form is invalid")            
    
    return http.HttpResponseRedirect("/")
Example #5
0
File: views.py Project: uve/onarena
def league_stat(request,league_id=None, format='html'):


    league = api.league_get(league_id)
    if not league:
        return http.HttpResponse()   
            
    tournament = league.tournament_id
  

    logging.info("format:   %s", format)

    area = 'league'
     
    if format == 'html':
        all_goals = api.statistics(league_id = league_id, limit = 1000)
        return api.response_get(request, locals(), 'league/templates/stat.html') 

    league = api.stat_league(league_id = league_id)

    jsoncallback = request.REQUEST.get("jsoncallback")

    limit = request.REQUEST.get("limit")

    logging.info("%s", jsoncallback)

    all_goals = api.statistics(league_id = league_id, limit = limit)
    c = template.RequestContext(request, locals())

    if format == 'json':
  
        t = loader.get_template('league/templates/stat.json')
        return util.HttpJsonResponse(t.render(c), request)
Example #6
0
File: views.py Project: 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')     
Example #7
0
File: views.py Project: uve/onarena
def tournament_index(request, format='html'):

    #all_tournaments = api.tournament_browse(sport_id = "1001")
    
    #all_tournaments = api.tournament_browse(limit=1000)
    
    #logging.info("request.META: %s",request.META)
    
    #form = models.TournamentForm() # An unbound form
    #all_sports = api.sport_browse(limit = 1000)
    
    #defers = {  "all_tournaments": deferred.group(api.tournament_browse,  sport_id = "1001")  }
    
    defers = {  "all_tournaments": deferred.group(api.tournament_browse,  limit = 1000)  }    
    
    #defers = {}

    
    main_page = True
    
    is_map = True

    area = 'index'    
    
    if format == 'html':
        return api.response_get(request, locals(), 'common/templates/index.html', defers = defers) 
Example #8
0
File: views.py Project: 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')     
Example #9
0
File: views.py Project: uve/onarena
def news_item(request, news_id = None, format='html'):
    
    area = 'news'    
        
    news = api.news_get(news_id = news_id)

    if format == 'html':
        return api.response_get(request, locals(), 'news/templates/item.html') 
Example #10
0
File: views.py Project: uve/onarena
def regulations_item(request, tournament_id=None, format='html'):

    regulations = api.regulations_get(tournament_id = tournament_id)
    
    if regulations is None and request.is_owner:
        return http.HttpResponseRedirect("/tournament/" + tournament_id + "/regulations/edit/")        

    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/regulations_item.html') 
Example #11
0
File: views.py Project: uve/onarena
def tournament_team_browse(request, tournament_id = None, format='html'):
    

    tournament = api.tournament_get(tournament_id = tournament_id)
    all_teams = api.team_browse_rating(tournament_id = tournament_id)   
    
    area = 'tournament'    
    
    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/team_browse.html')         
Example #12
0
File: views.py Project: uve/onarena
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')   
Example #13
0
File: views.py Project: uve/onarena
def referee_item(request,referee_id = None, format='html'):

    referee = api.referee_get(referee_id = referee_id, is_reload = True)
   
    if not referee:
        return http.HttpResponse()
    
    
    area = 'referee'
    load_async = "referee_item"
    

    if format == 'html':
        return api.response_get(request, locals(), 'referee/templates/item.html') 
Example #14
0
File: views.py Project: uve/onarena
def player_item(request, player_id = None, format='html'):

    player = api.player_get(player_id = player_id)
    
    team_id = request.REQUEST.get('team_id', '')
    
    if not player:
        return http.HttpResponse()
            
    player_stat = api.player_stat_get(player_id = player_id)
    
    area = 'player'

    if format == 'html':
        return api.response_get(request, locals(), 'player/templates/item.html') 
Example #15
0
File: views.py Project: uve/onarena
def referee_create(request, format='html'):

    tournament_id = request.REQUEST.get('tournament_id', '')
    tournament = api.tournament_get(tournament_id = tournament_id)

    if request.POST and request.is_owner:
        item = api.referee_create(request = request)
        #return http.HttpResponseRedirect("/referee/" + str(item) + "/")
        #item = request.POST["team_id"]
            
        return http.HttpResponseRedirect("/tournament/" + tournament_id + "/referees/")
    
    area = 'referee'
    
    if format == 'html':
        return api.response_get(request, locals(), 'referee/templates/create.html')     
Example #16
0
File: views.py Project: uve/onarena
def tournament_item(request, tournament_id = None, format='html'):

    #tournament = api.tournament_get(tournament_id)
    #all_leagues = api.league_browse(tournament_id = tournament_id)   
    
    tournament = api.tournament_get(tournament_id = tournament_id)
    
    defers = {  #"tournament": deferred.group(api.tournament_get, tournament_id = tournament_id),
                #"all_leagues": deferred.group(api.league_browse,  tournament_id = tournament_id)  
                }
    
    area = 'tournament'    
    
    is_map = True
        
    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/item.html', defers = defers) 
Example #17
0
File: views.py Project: uve/onarena
def tournament_test(request,tournament_id=None, format='html'):

    #api.test()#:api.rating_update(tournament_id = "1001")
    
    #return http.HttpResponse(status = 200)    
    
    all_results = api.test()
    return api.response_get(request, locals(), 'tournament/templates/test.html') 
    
    if api.test():
        status_code = 200
    else:
        status_code = 301

    logging.info("Status Code: %s", status_code)        

    return http.HttpResponse(status = status_code)
Example #18
0
File: views.py Project: uve/onarena
def league_create(request, format='html'):

    if request.POST and request.is_owner:
        item = api.league_create(request)
        return http.HttpResponseRedirect("/league/" + str(item) + "/")
        
    owned_tournaments = request.user.user_tournaments

    area = 'league'
    c = template.RequestContext(request, locals())

    #if format == 'html':
    #    t = loader.get_template('league/templates/create.html')
    #    return http.HttpResponse(t.render(c))
    
     
    if format == 'html':
        return api.response_get(request, locals(), 'league/templates/create.html') 
Example #19
0
File: views.py Project: uve/onarena
def news_create(request, tournament_id = None, format='html'):  
        
    if request.is_owner:    
        if request.POST:
            item = api.news_create(request)
            return http.HttpResponseRedirect("/news/" + str(item) + "/")
    
        else:
            tournament = request.tournament

            area = 'news'

            if format == 'html':
                return api.response_get(request, locals(), 'news/templates/create.html')                 
                
                
    else:
        logging.critical("No Access!!!")
        return http.HttpResponse()                    
Example #20
0
File: views.py Project: uve/onarena
def tournament_create_step2(request, format='html'):  
        
    if request.method == 'POST':
        form = models.TournamentForm(request.POST)
        if form.is_valid():             
            item = api.tournament_create(request = request, form = form)
            return http.HttpResponseRedirect("/tournament/" + str(item) + "/")
        else:
            logging.info("Form is invalid")            
    
    form = models.TournamentForm() # An unbound form
    all_sports = api.sport_browse(limit = 1000)
    
    logging.info("hes: %s", all_sports)

    area = 'tournament'    
    
    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/create.html')                                         
Example #21
0
File: views.py Project: uve/onarena
def regulations_edit(request, tournament_id=None, format='html'):

    if not request.is_owner:
        return http.HttpResponseRedirect("/tournament/" + tournament_id + "/")     
               
    regulations = api.regulations_get(tournament_id = tournament_id)
    
    if request.POST and request.is_owner:
        content = request.POST.get("content", "")
        logging.info("content: %s",content)
        item = api.regulations_edit(content = content, tournament_id = tournament_id)
            
        return http.HttpResponseRedirect("/tournament/" + tournament_id + "/regulations/")
        

    area = 'regulations'
        
    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/regulations_edit.html')     
Example #22
0
File: views.py Project: 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')     
Example #23
0
File: views.py Project: 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') 
Example #24
0
File: views.py Project: uve/onarena
def referee_edit(request,referee_id = None,  format='html'):



    referee = api.referee_get(referee_id = referee_id)
    if not referee:
        return http.HttpResponse()


    if not request.is_owner:
        return http.HttpResponseRedirect("/referee/" + referee_id + "/")        
        
    if request.POST and request.is_owner:
        item = api.referee_edit(request = request, referee_id = referee_id)
            
        return http.HttpResponseRedirect("/referee/" + referee_id + "/")

    area = 'referee'
    
    if format == 'html':
        return api.response_get(request, locals(), 'referee/templates/edit.html')     
Example #25
0
File: views.py Project: uve/onarena
def tournament_edit(request, tournament_id = None, format='html'):

    tournament = api.tournament_get(tournament_id = tournament_id)
    if not tournament:
        return http.HttpResponse()
        
    if not request.is_owner:
        return http.HttpResponseRedirect("/tournament/" + tournament_id + "/")         
        
    if request.method == 'POST':
        form = models.TournamentFormEdit(request.POST)
        if form.is_valid():             
            item = api.tournament_edit(form = form, tournament_id = tournament_id)
            return http.HttpResponseRedirect("/tournament/" + tournament_id + "/")
    else:
        form = models.TournamentFormEdit(tournament) # An unbound form

    area = 'team'
        
    if format == 'html':
        return api.response_get(request, locals(), 'tournament/templates/edit.html')          
Example #26
0
File: views.py Project: uve/onarena
def league_item(request, league_id = None, format='html'):

    area = 'league'
    load_async = 'league_item'  
    
    league = models.League.get_item(league_id)
    if not league:
        return http.HttpResponse()    
    
    
    defers = {  "league":       deferred.group(api.stat_league,    league_id = league_id),
                "all_goals":    deferred.group(api.statistics,     league_id = league_id),
                
                
                #"all_teams":    deferred.group(api.team_browse,    league_id = league_id),
                
                #"all_matches":  deferred.group(api.match_browse,   league_id = league_id),
                #"all_playoffs": deferred.group(api.playoff_browse, league_id = league_id), 
                }   
                
    '''    
    if request.REQUEST.get("is_reload"):
        all_groups = api.group_browse(league_id = league_id, is_reload = True)   
    else:
        defers["all_groups"] = deferred.group(api.group_browse,   league_id = league_id)
    '''                            
                
    #if request.is_owner:
    #    defers["all_playoff_teams"] = deferred.group(api.team_browse, tournament_id = request.tournament_id)
                        
                             
        
    #logging.info("request: %s",request)
    
    items = {'area': area, 'load_async': load_async, 'league': league, 'league_id': league_id}

    if format == 'html':
        return api.response_get(request, items, 'league/templates/item.html', defers = defers) 
Example #27
0
File: views.py Project: uve/onarena
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')    
Example #28
0
def sitemap(request, format='html'):

    deferred.defer(api.sitemap, name = "tournaments")      
    deferred.defer(api.sitemap, name = "leagues")  
    deferred.defer(api.sitemap, name = "teams")  
    #deferred.defer(api.sitemap, name = "players")  
    #deferred.defer(api.sitemap, name = "matches")      
    

    defers = {  "all_tournaments": deferred.group(api.sitemap, name = "tournaments"),
                "all_leagues":     deferred.group(api.sitemap, name = "leagues"),
                "all_teams":       deferred.group(api.sitemap, name = "teams"),
                #"all_matches":     deferred.group(api.sitemap, name = "matches"),                
                #"all_players":     deferred.group(api.sitemap, name = "players"),  
                }    
  
  

    
    today = datetime.today()
    
    if format == 'html':
        return api.response_get(request, locals(), 'common/templates/sitemap.html')
Example #29
0
File: views.py Project: uve/onarena
def news_edit(request, news_id = None,  format='html'):

    if not request.is_owner:
        return http.HttpResponseRedirect("/news/" + news_id + "/")        
   

    if request.POST and request.is_owner:

        name    = request.POST.get("name")
        content = request.POST.get("content")   
        
        item = api.news_edit(news_id = news_id, name = name, content = content)
            
        return http.HttpResponseRedirect("/news/" + news_id + "/")


    news = api.news_get(news_id = news_id)
    if not news:
        return http.HttpResponse()

    area = 'news'
    
    if format == 'html':
        return api.response_get(request, locals(), 'news/templates/edit.html')  
Example #30
0
def about_us(request, format='html'):
    if format == 'html':
        return api.response_get(request, locals(), 'common/templates/about_us.html')