示例#1
0
    def get(self, filter=''):
        self.get_template_values()
        if filter == '': filter = 'ko'
        if filter == 'group': filter = Fifa2014().groupstage.key()
        if filter == 'ko': filter = Fifa2014().kostage.key()
        self.template_values['games'] = GroupGame.byKey(filter).widewalk()

        MainHandler.get(self,'games')
示例#2
0
    def submenu(self, page):
        subgames = GroupGame.everything().values()
        subgames.sort(key=GroupGame.groupstart)
        groupgames = []
        for game in subgames:
            if not game.upgroup() is None and str(game.upgroup().key()) == str(Fifa2014().groupstage.key()):
                groupgames.append(game)
            if not game.upgroup() is None and str(game.upgroup().key()) == str(Fifa2014().kostage.key()):
                groupgames.append(game)

        self.template_values['filtergames'] = groupgames
        self.template_values['filter'] = filter
        self.template_values['filter_uri'] = '/' + page
示例#3
0
    def get(self, filter = ''):
        self.get_template_values()
        self.submenu('scoreboard')
        if filter == '': filter = Fifa2014().tournament.key()
        groupgame = GroupGame.get(filter)

        self.template_values['groupgame'] = groupgame
        self.template_values['multiplier'] = pool.group_multiplier(groupgame)
        scoreboard = pool.scoreboard(LocalUser.actives(), Fifa2014().result, groupgame)
        self.template_values['scoreboard'] = scoreboard

        subgroups = groupgame.subgames()
        subgroups.sort(key=GroupGame.groupstart)
        self.template_values['subgames'] = subgroups
        self.template_values['subboards'] = [{'game':subgroup,'multiplier':pool.group_multiplier(subgroup),'scorelines':pool.scoreboard(LocalUser.actives(), Fifa2014().result, subgroup)} for subgroup in subgroups]

        MainHandler.get(self,'scoreboard')
示例#4
0
 def get(self):
     self.get_template_values()
     singlegames = SingleGame.all().filter('time >=',NOW+timedelta(days=-2)).filter('time <=',NOW+timedelta(days=2)).order('time').fetch(12)
     if self.current_user():
         self.template_values['games'] = [{
             'game':singlegame,
             'bet':self.current_user().singlegame_result(singlegame),
             'result':Fifa2014().result.singlegame_result(singlegame),
             'point':pool.singlegame_result_point(self.current_user().singlegame_result(singlegame), Fifa2014().result.singlegame_result(singlegame))
             } for singlegame in singlegames]
     else:
         self.template_values['games'] = [{
             'game':singlegame,
             'bet':{'locked':False},
             'result':Fifa2014().result.singlegame_result(singlegame)
             } for singlegame in singlegames]
     MainHandler.get(self,'today')
示例#5
0
    def get(self, filter=''):
        self.get_template_values()
        self.submenu('mytips')
        if filter == '':
            filtered = [game for game in SingleGame.everything().itervalues() if game.time+timedelta(minutes=120) > NOW]
            filtered.sort(cmp=lambda x,y: cmp(x.time, y.time))
            if len(filtered) > 0:
                if filtered[0] != None:
                    filter = filtered[0].group().key()
        groupgame = GroupGame.get(filter)
        if len(groupgame.singlegames()) == 0:
            groupgames = groupgame.groupgames()
        else:
            groupgames = [groupgame]
        tpl_groupgames = []
        for game in groupgames:
            if len(game.singlegames()) > 0:
                groupgame = {'game':game,'singlegames':[]}
                for singlegame in game.singlegames():
                    bet = self.current_user().singlegame_result(singlegame)
                    result = Fifa2014().result.singlegame_result(singlegame)
                    point = pool.singlegame_result_point(bet, result)
                    groupgame['singlegames'].append({
                        'game':singlegame,
                        'bet':bet,
                        'editable': (str(self.current_user().key()) == str(Fifa2014().result.key()) and NOW > singlegame.time and not bet.locked)
                            or (not bet.locked and not result.locked and NOW < game.groupstart()),
                        'result':result,
                        'point':point})
                groupbet = self.current_user().groupgame_result(game)
                groupresult = Fifa2014().result.groupgame_result(game)
                groupgame['editable'] = (not groupbet.locked and not groupresult.locked and NOW < game.groupstart()) or str(self.current_user().key()) == str(Fifa2014().result.key())
                groupgame['bet'] = groupbet
                groupgame['bet_ranking'] = groupbet.get_ranks()
                groupgame['result_ranking'] = groupresult.get_ranks()
                groupgame['point'] = pool.groupgame_result_point(groupbet, groupresult)
                tpl_groupgames.append(groupgame)

        self.template_values['groupgames'] = tpl_groupgames
        self.template_values['scorelist'] = [''] + Result.score_list()

        MainHandler.get(self,'mytips')
示例#6
0
    def get(self, filter=''):
        self.get_template_values()
        self.submenu('alltips')
        if filter == '':
            filtered = [game for game in SingleGame.everything().itervalues() if game.time <= NOW]
            filtered.sort(cmp=lambda x,y: cmp(x.time, y.time), reverse=True)
            if len(filtered) > 0:
                filter = filtered[0].group().key()
            else:
                filter = Fifa2014().groupstage.key() 

        users = [user for user in LocalUser.actives()]
        self.template_values['users'] = users

        groupgame = GroupGame.get(filter)
        if len(groupgame.singlegames()) == 0:
            groupgames = groupgame.groupgames()
        else:
            groupgames = [groupgame]
        tpl_groupgames = []

        for group in groupgames:
            tpl_groupgame = {}
            if(len(group.singlegames()) > 0):
                tpl_groupgame['groupgame'] = group
                tpl_groupgame['alltips'] = []
                for singlegame in group.singlegames():
                    result = self.current_user().singlegame_result(singlegame)
                    if result.locked or NOW > group.groupstart():
                        tpl_groupgame['alltips'].append({'game': singlegame,
                            'tips': self.singlegame_tips(singlegame, users)
                            })
                    else:
                        tpl_groupgame['alltips'].append({'game': singlegame})
                tpl_groupgame['ranks'] = self.groupgame_tips(group, users)
            tpl_groupgames.append(tpl_groupgame)

        self.template_values['groupgames'] = tpl_groupgames
        MainHandler.get(self,'alltips')
示例#7
0
    def get(self, *args):
        self.get_template_values()
        if not users.is_current_user_admin():
            self.redirect(users.create_login_url(self.request.uri))
            return
        if len(args) > 0:
            admin = args[0]
            if "flush" == admin:
                perm_cached_class(None, flush=True)
            if "fifa" == admin:
                Fifa2014.init_tree()
                perm_cached_class(None, flush=True)
                self.redirect('/admin/team')
            elif "team" == admin:
                if len(args) > 1:
                    self.template_values['team'] = Team.all().filter('short =',args[1]).get()
                    self.render('admin/team')
                else:
                    self.template_values['teams'] = Team.all()
                    self.render('admin/teams')
            elif "game" == admin:
                if len(args) > 1:
                    game = SingleGame.byKey(args[1])
                    if self.request.get('save') == "Submit":
                        game.homeTeam_ref = Team.byKey(self.request.get('homeTeam'))
                        game.awayTeam_ref = Team.byKey(self.request.get('awayTeam'))
                        game.put()
                    self.template_values['game'] = game
                    self.template_values['teams'] = Team.all()
                    self.render('admin/game')
                    pass
                else:
                    self.template_values['groupgames'] = GroupGame.all().order('name')
                    self.template_values['singlegames'] = SingleGame.all().order('time')
                    self.render('admin/games')
            elif "user" == admin:
                if len(args) > 1:
                    pass
                else:
                    self.template_values['users'] = LocalUser.all()
                    #print pool.score_group(self.current_user(),Fifa2014().result,Fifa2014().tournament)
                    self.render('admin/users')
            elif "result" == admin:
                if self.request.get('save') == "Submit":
                    user = LocalUser.get(self.request.get('filter_user'))
                    singlegame = SingleGame.byKey(self.request.get('filter_game'))
                    singlegame.results(nocache=True)
                    result = user.singlegame_result(singlegame)
                    result.homeScore = int(self.request.get('homeScore'))
                    result.awayScore = int(self.request.get('awayScore'))
                    result.locked = True
                    result.put()
                    pool.flush_singlegame(singlegame)
                    user.singleresults(nocache=True)
                self.template_values['users'] = LocalUser.actives()
                self.template_values['singlegames'] = [{'key':game.key(),
                    'groupname':game.group().name,
                    'time':game.time,
                    'homeTeam':game.homeTeam(),
                    'awayTeam':game.awayTeam()} for game in SingleGame.everything().itervalues() if game.homeTeam()]
                self.template_values['singlegames'].sort(cmp=lambda x,y: cmp(x['time'], y['time']))
                self.template_values['singlegames'].sort(cmp=lambda x,y: cmp(x['groupname'], y['groupname']))

                betQuery = Result.all()
                groupbetQuery = GroupResult.all()

                filter_game_key = self.request.get("filter_game")
                if filter_game_key:
                    filter_game = SingleGame.everything()[filter_game_key]
                    self.template_values['filter_game'] = filter_game
                    betQuery = betQuery.filter("singlegame = ",filter_game)
                    groupbetQuery = groupbetQuery.filter("singlegame = ",filter_game)

                filter_user_key = self.request.get("filter_user")
                if filter_user_key:
                    filter_user = LocalUser.get(filter_user_key)
                    self.template_values['filter_user'] = filter_user
                    betQuery = betQuery.filter("user = "******"user = ",filter_user)
                self.template_values['bets'] = betQuery.fetch(32)
                self.template_values['groupbets'] = groupbetQuery.fetch(32)
                self.render('admin/bets')
            else:
                self.render('admin/layout')
        else:
            self.render('admin/layout')
示例#8
0
 def get(self):
     self.get_template_values()
     self.template_values['perfects'] = pool.perfects_group(LocalUser.actives(),Fifa2014().result,Fifa2014().tournament)
     self.render('perfect')