Beispiel #1
0
 def get(self):
   #TODO(kushal): Support location filter
   all_teams = Team.all().fetch(1000)
   for team in all_teams:
     team.totalvotes = team.votes + team.local_votes
   all_teams.sort(key=attrgetter('totalvotes'))
   self.render('winners', { 'teams': all_teams })
Beispiel #2
0
 def get(self):
   if not checkAdmin(users.get_current_user().email()):
     return self.error(403)
   #TODO(kushal): Support location filter
   all_teams = filter_hidden(Team.all().fetch(1000))
   for team in all_teams:
     team.totalvotes = team.votes + team.local_votes
   all_teams.sort(key=attrgetter('totalvotes'))
   self.render('winners', { 'teams': all_teams })
Beispiel #3
0
    def init_team(self, team):
        """Create team if not exists."""

        team_stored = Team.all().filter('name =', team['name']).get()
        if team_stored is None:
            team_stored = Team(name=team['name'])
            short_match = re.search(r'([a-z]{3})\.gif$', team['flag'])
            team_stored.flag = team['flag']
            team_stored.short = short_match.group(1)
            team_stored.href = team['href']
            team_stored.put()

        return team_stored
Beispiel #4
0
    def init_team(self, team):
        """Create team if not exists."""

        team_stored = Team.all().filter('name =',team['name']).get()
        if team_stored is None:
            team_stored = Team(name=team['name'])
            short_match = re.search(r'([a-z]{3})\.gif$',team['flag'])
            team_stored.flag = team['flag']
            team_stored.short = short_match.group(1)
            team_stored.href = team['href']
            team_stored.put()

        return team_stored
Beispiel #5
0
    def init_team(self, team):
        """Create team if not exists."""

        team_stored = Team.all().filter('name =',team['name']).get()
        if team_stored is None:
            team_stored = Team(name=team['name'])
            short_match = re.search(r'([a-z]{3})\.png$',team['flag'])
            team_stored.flag = team['flag']
            team_stored.short = short_match.group(1)
            team_stored.href = "http://www.uefa.com/" + team['href']
            team_stored.teamId = re.match(r'/uefaeuro/season=2012/teams/team=([0-9]+)/index.html', team['href']).group(1)
            team_stored.put()

        return team_stored
Beispiel #6
0
  def get(self):  
    current_user = users.get_current_user()
    votes = Votes.for_user(current_user)
    
    team_comments = {}
    user_comments = {}
      
    if shouldShowComments():
      comments = Comment.all()
      for comment in comments:
        team_key = str(comment.team.key())
        comment.author_name = generateCommentAuthorName(comment)
        if not team_key in team_comments:
          team_comments[team_key] = []
        if comment.user == current_user:
          user_comments[team_key] = comment
        team_comments[team_key].append(comment)
            
    all_teams = filter_hidden(Team.all().fetch(1000))
    for team in all_teams:
      team.voted = (team.key() in votes.local_teams or team.key() in votes.teams)
      team_key = str(team.key())
      if shouldShowComments():
        if team_key in team_comments:
          team.comments = team_comments[team_key]
        if team_key in user_comments:
          team.user_comment = user_comments[team_key].text
    
    logout_url = users.create_logout_url("/")

    winning_teams = filter(lambda x: config['highlight_winners'] and x.annotation is not None and x.annotation != '', all_teams)
    all_teams = filter(lambda x: x not in winning_teams, all_teams)

    # Disable randomness for commenting always
    if config["list_teams_randomly"] and not shouldEnableCommenting():
      random.shuffle(all_teams)
      random.shuffle(winning_teams)
      
    self.render('list', { 'teams': all_teams,
                          'winning_teams': winning_teams,
                          'votes': votes,
                          'team_comments': team_comments,
                          'user_comments': user_comments,
                          'highlight_winners': config['highlight_winners'],
                          'enable_voting': config['enable_voting'],
                          'enable_commenting': shouldEnableCommenting(),
                          'show_winner_entry': config['show_winner_entry'],
                          'logout_url': logout_url })
Beispiel #7
0
    def init_team(self, team):
        """Create team if not exists."""

        team_stored = Team.all().filter('name =', team['name']).get()
        if team_stored is None:
            team_stored = Team(name=team['name'])
            short_match = re.search(r'([a-z]{3})\.png$', team['flag'])
            team_stored.flag = team['flag']
            team_stored.short = short_match.group(1)
            team_stored.href = "http://www.uefa.com/" + team['href']
            team_stored.teamId = re.match(
                r'/uefaeuro/season=2012/teams/team=([0-9]+)/index.html',
                team['href']).group(1)
            team_stored.put()

        return team_stored
Beispiel #8
0
  def get(self):  
    current_user = users.get_current_user()
    votes = Votes.for_user(current_user)
    
    team_comments = {}
    user_comments = {}
      
    if shouldShowComments():
      comments = Comment.all()
      for comment in comments:
        team_key = str(comment.team.key())
        comment.author_name = comment.user.nickname().split('@', 1)[0]
        if not team_key in team_comments:
          team_comments[team_key] = []
        if comment.user == current_user:
          user_comments[team_key] = comment
        team_comments[team_key].append(comment)
            
    all_teams = Team.all().fetch(1000)
    for team in all_teams:
      team.voted = (team.key() in votes.local_teams or team.key() in votes.teams)
      team_key = str(team.key())
      if shouldShowComments():
        if team_key in team_comments:
          team.comments = team_comments[team_key]
        if team_key in user_comments:
          team.user_comment = user_comments[team_key].text
    
    logout_url = users.create_logout_url("/")

    # Disable randomness for commenting always
    if config["list_teams_randomly"] and not shouldEnableCommenting():
      random.shuffle(all_teams)
      
    self.render('list', { 'teams': all_teams,
                          'votes': votes,
                          'team_comments': team_comments,
                          'user_comments': user_comments,
                          'enable_voting': config['enable_voting'],
                          'enable_commenting': shouldEnableCommenting(),
                          'logout_url': logout_url })