Esempio n. 1
0
 def get(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         if session.has_key('active_user'):
             template_values = {
                 'session_status': True,
                 'user': session['active_user'],
                 'top_scorers': get_top_scorers(),
                 'top_users': get_top_users_global_ranking(),
                 'last_jackpot': get_last_jackpot(),
                 'error': ''
             }
         else:
             session.terminate()
             
             template_values = {
                 'session_status': False,
                 'top_scorers': get_top_scorers(),
                 'top_users': get_top_users_global_ranking(),
                 'last_jackpot': get_last_jackpot(),
                 'error': ''
             }
     else:
         template_values = {
             'session_status': False,
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot(),
             'error': ''
         }
         
     render_template(self, 'register.html', template_values)
Esempio n. 2
0
 def get(self):
     session = get_current_session()
     
     check_session_status()
         
     if session.is_active():
         active_user = session['active_user']
         
         active_user_football_pools = CAFootballPool.all().filter("user ="******"privacy =", False).fetch(1000)
         
         football_pools_info = []
         
         for football_pool in active_user_football_pools:
             if not football_pool.payment:
                 football_pools_info.append((football_pool.name, 'Por Pagar', '-'))
             else:
                 if football_pool.payment.status:
                     football_pools_info.append((football_pool.name, 'Pagada', str(get_total_points(football_pool))))
                 else:
                     football_pools_info.append((football_pool.name, 'Esperando Confirmación de Pago', '-'))
         
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'football_pools_info': football_pools_info,
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }
         
         render_template(self, 'user_profile.html', template_values)
     else:
         self.redirect('/')
Esempio n. 3
0
 def post(self):
     name = self.request.get('name')
     email = self.request.get('email')
     password = self.request.get('password')
     
     existing_google_user = CAUser.all().filter("google_user !=", None).fetch(10000)
     exists = False
     
     for user in existing_google_user:
         if user.google_user.email() == email:
             exists = True
             break
     
     if not exists:
         existing_user = CANativeUser.all().filter("email =", email).fetch(10000)
         
         if not existing_user:
             user = CANativeUser(name=name, email=email, password=password)
             user.put()
             
             ca_user = CAUser(native_user=user, type=2)
             ca_user.put()
         
             self.redirect('/login')
         else:
             template_values = {
                 'session_status': False,
                 'top_scorers': get_top_scorers(),
                 'top_users': get_top_users_global_ranking(),
                 'last_jackpot': get_last_jackpot(),
                 'error': 'Ya existe un usuario registrado con este correo electrónico. Inténtalo de nuevo'
             }
             
             render_template(self, 'register.html', template_values)
     else:
         template_values = {
             'session_status': False,
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot(),
             'error': 'Ya existe un usuario registrado con este correo electrónico. Inténtalo de nuevo'
         }
         
         render_template(self, 'register.html', template_values)
 def post(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
     
     if session.is_active():
         original_pool = CAFootballPool.all().filter("privacy =", True).fetch(1)[0]
         first_round_matches = original_pool.first_round_matches.fetch(18)
         final_matches = []
         
         for match in first_round_matches:
             team_list = db.get(match.teams)
             match_list = []
             
             key0 = team_list[0].name[:3]
             key1 = team_list[1].name[:3]
             
             final_key1 = key0 + '-' + key1 + '-g1'
             final_key2 = key0 + '-' + key1 + '-g2'
             
             match_list.append(final_key1)
             match_list.append(self.request.get(final_key1))
             match_list.append(final_key2)
             match_list.append(self.request.get(final_key2))
             
             final_matches.append(match_list)
         
         first_round_winners = eval(self.request.get('first-round-winners'))
         quarter_finals_teams = []
         
         counter = 1
         for winners in first_round_winners:
             initials = winners[1].partition('-')
             team_names = []
             team_names.append(get_team_whole_name(initials[0]))
             team_names.append(get_team_whole_name(initials[2]))
             team_names.append(counter)
             quarter_finals_teams.append(team_names)
             counter += 1
             
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'football_pool_name': self.request.get('football-pool-name'),
             'first_round_matches': str(final_matches),
             'quarter_finals_teams': quarter_finals_teams,
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }     
         
         render_template(self, 'create_step2.html', template_values)
     else:
         self.redirect('/')
Esempio n. 5
0
 def get(self):
     session = get_current_session()
     
     check_session_status()
         
     if session.is_active():
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }
     else:
         template_values = {
             'session_status': False,
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }
         
     render_template(self, 'rules.html', template_values)
 def get(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         user_key = Key(self.request.get('user'))
         
         new_member = CAUser.get(user_key)
         
         username = []
         
         members = eval(self.request.get('last_members'))
         searched_users = eval(self.request.get('last_search')) 
                         
         if new_member.type == 0:
             username = new_member.google_user.nickname() + " " + new_member.google_user.email()
         elif new_member.type == 1:
             username = new_member.facebook_user.name
         else:
             username = new_member.native_user.name + " " + new_member.native_user.email
                     
         if username:
             searched_users.remove((str(username), str(new_member.key())))
             members.append((str(username), str(new_member.key()), True))
             
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'searched_users': searched_users,
             'members': members,
             'name': self.request.get('name'),
             'last_search': str(searched_users),
             'last_members': str(members),
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot(),
             'selected_football_pool': self.request.get('selected-football-pool')
         }
                 
         render_template(self, 'edit_competition_group.html', template_values)
     else:
         self.redirect('/')
    def get(self):
        update_session_time()
        session = get_current_session()
        check_session_status()
            
        if session.is_active():
            selected_competition_group_key = Key(self.request.get('id'))
            competition_group = CACompetitonGroup.get(selected_competition_group_key)
            
            members = competition_group.members.fetch(10000)
            current_members = []
            
            for user in members:
                username = ''
                
                if user.type == 0:
					username = user.google_user.nickname() + " " + user.google_user.email()
                elif user.type == 1:
                    username = user.facebook_user.name
                else:
					username = user.native_user.name + " " + user.native_user.email
            
                if username:
					current_members.append((str(username), str(user.key()), False))
            
            template_values = {
                'session_status': True,
                'user': session['active_user'],
                'searched_users': [],
                'members': current_members,
                'name': competition_group.name,
                'last_search': str([]),
                'last_members': str(current_members),
                'top_scorers': get_top_scorers(),
                'top_users': get_top_users_global_ranking(),
                'last_jackpot': get_last_jackpot(),
                'selected_football_pool': str(selected_competition_group_key)
            }
            
            render_template(self, 'edit_competition_group.html', template_values)
        else:
            self.redirect('/')
Esempio n. 8
0
 def get(self):
     session = get_current_session()
     
     check_session_status()
         
     if session.is_active():
         if session.has_key('active_user'):
             active_user = session['active_user']
             
             global_competition_group = CACompetitonGroup.all().filter("privacy =", True).fetch(1)[0]
             global_rank = CAGroupRanking.gql("WHERE group = :1 ORDER BY rank", global_competition_group.key()).fetch(10000)
             
             global_rank_list = []
             
             for rank in global_rank:
                 if rank.user.key() == active_user.key():
                     current_user = True
                 else:
                     current_user = False
                 
                 if rank.user.type == 0:
                     user_name = rank.user.google_user
                 elif rank.user.type == 1:
                     user_name = rank.user.facebook_user.name
                 else:
                     user_name = rank.user.native_user.name
                 
                 global_rank_list.append((user_name, rank.rank, current_user))
             
             template_values = {
                 'session_status': True,
                 'user': session['active_user'],
                 'ranking': global_rank_list,
                 'competition_group_name': global_competition_group.name,
                 'top_scorers': get_top_scorers(),
                 'top_users': get_top_users_global_ranking(),
                 'last_jackpot': get_last_jackpot()
             }
             
             render_template(self, 'view_global_ranking.html', template_values)
     else:
         self.redirect('/')
Esempio n. 9
0
 def post(self):
     session = get_current_session()
     
     check_session_status()
         
     if session.is_active():
         save = self.request.get('save')
         
         active_user = session['active_user']
         message = ''
         
         if active_user.type == 2:
             if save:
                 native_user = CANativeUser.get(active_user.native_user.key())
                 
                 native_user.name = self.request.get('name')
                 native_user.email = self.request.get('email')
                 native_user.password = self.request.get('password')
                 native_user.put()
                 
                 active_user.native_user = native_user
                 active_user.put()
                 
                 session['active_user'] = active_user
                 message = 'Sus datos fueron actualizados exitosamente' 
                 
         active_user_football_pools = CAFootballPool.all().filter("user ="******"privacy =", False).fetch(1000)
         
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'football_pools': active_user_football_pools,
             'message': message,
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }
                 
         render_template(self, 'list_football_pools_to_view.html', template_values)
     else:
         self.redirect('/')
 def get(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'searched_users': [],
             'members': [],
             'name': '',
             'last_search': str([]),
             'last_members': str([]),
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }
         
         render_template(self, 'create_competition_group.html', template_values)
     else:
         self.redirect('/')
 def get(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         active_user = session['active_user']
         
         competition_groups = CACompetitonGroup.get(active_user.groups)
         
         template_values = {
             'session_status': True,
             'user': active_user,
             'groups': competition_groups,
             'pending_membership_requests': get_pending_membership_requests(active_user),
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot()
         }
         
         render_template(self, 'list_competition_groups_to_view.html', template_values)
     else:
         self.redirect('/')
 def get(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         if session.has_key('active_user'):
             active_user = session['active_user']
             
             active_user_football_pools = CAFootballPool.all().filter("user ="******"privacy =", False).fetch(1000)
             
             sandra_key = Key('ag5zfnR1cXVpbmllbGFjYXIOCxIGQ0FVc2VyGJqdAQw')
             christian_key = Key('ag5zfnR1cXVpbmllbGFjYXINCxIGQ0FVc2VyGNR1DA')
             mariel_key = Key('ag5zfnR1cXVpbmllbGFjYXIOCxIGQ0FVc2VyGIG0AQw')
             francisco_key = Key('ag5zfnR1cXVpbmllbGFjYXIOCxIGQ0FVc2VyGIbUAQw')
             
             ca_user_key = active_user.key()
             
             special_user = False
             
             if ca_user_key == sandra_key or ca_user_key == christian_key or ca_user_key == mariel_key or ca_user_key == francisco_key:
                 special_user = True
             
             template_values = {
                 'session_status': True,
                 'user': active_user,
                 'football_pools': active_user_football_pools,
                 'message':'',
                 'top_scorers': get_top_scorers(),
                 'top_users': get_top_users_global_ranking(),
                 'last_jackpot': get_last_jackpot(),
                 'special_user': special_user
             } 
             
             render_template(self, 'list_football_pools_to_pay.html', template_values)
     else:
         self.redirect('/')
 def post(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         selected = self.request.get('selected_competition_group')
         
         edit = self.request.get('edit')
         ranking = self.request.get('ranking')
         
         if selected != "default":
             selected_competition_group_key = Key(selected)
             
             if edit:
                 global_group = CACompetitonGroup.all().filter("privacy =", True).fetch(1)[0]
                 
                 if (selected_competition_group_key != global_group.key()):
                     self.redirect('/edit/group?id=' + selected)
                 else:
                     self.redirect('/list/groups/view')
             elif ranking:
                 competition_group = CACompetitonGroup.get(selected_competition_group_key)
                 
                 group_ranking = CAGroupRanking.all().filter("group =", selected_competition_group_key).fetch(10000)
                 
                 active_user = session['active_user']
                 active_user_football_pools = active_user.football_pools
                 
                 active_user_football_pools_keys = []
                 for football_pool in active_user_football_pools: 
                     active_user_football_pools_keys.append(football_pool.key())
                 
                 group_ranking_list = []
                 
                 for rank in group_ranking:
                     if rank.football_pool.key() in active_user_football_pools_keys:
                         selected = True
                     else:
                         selected = False
                     
                     if rank.football_pool.user.type == 0:
                         name = rank.football_pool.user.google_user.nickname()
                     elif rank.football_pool.user.type == 1:
                         name = rank.football_pool.user.facebook_user.name
                     else:
                         name = rank.football_pool.user.native_user.name
                         
                     group_ranking_list.append((name, rank.football_pool.name, get_total_points(rank.football_pool), selected, rank.football_pool.key()))
                     
                 sorted_group_ranking_list = sorted(group_ranking_list,key=lambda position: position[2], reverse=True)    
                 comments = CAGroupComment.all().filter("group =", competition_group).fetch(10000)
                 comments_info = []
                 
                 for comment in comments:
                     if comment.user.type == 0:
                         name = comment.user.google_user.nickname()
                     elif comment.user.type == 1:
                         name = comment.user.facebook_user.name
                     else:
                         name = comment.user.native_user.name
                         
                     comments_info.append((name, str(comment.date.day) + '/' + str(comment.date.month) + '/' + str(comment.date.year) + ' ' + str(comment.date.hour) + ':' + str(comment.date.minute), comment.comment))
                     
                 template_values = {
                     'session_status': True,
                     'user': active_user,
                     'competition_group_name': competition_group.name,
                     'group_ranking': sorted_group_ranking_list,
                     'top_scorers': get_top_scorers(),
                     'top_users': get_top_users_global_ranking(),
                     'last_jackpot': get_last_jackpot(),
                     'comments': comments_info,
                     'selected_group_key': self.request.get('selected_competition_group'),
                 }
                 
                 render_template(self, 'ranking.html', template_values)
         else:
             if edit:
                 self.redirect('/list/groups/view')
             elif ranking:
                 self.redirect('/list/groups/ranking')
     else:
         self.redirect('/')
    def post(self):
        update_session_time()
        session = get_current_session()
        check_session_status()
            
        if session.is_active():
            search_user = self.request.get('search_user')
            save = self.request.get('save')
            
            if search_user:
                active_user = session['active_user']
                
                search_term = self.request.get('search')
                search_result = []
                
                if search_term:
                    users = CAUser.all().fetch(10000)
                    logging.debug('Iterando por usuarios')

                    for user in users:
                        if active_user.key() != user.key():
                            username = []
                            
                            logging.debug('tipo de usuario: ' + str(user.type))
                            
                            if user.type == 0:
                                nickname = user.google_user.nickname()
                                email = user.google_user.email()

                                if (search_term.lower() in str(nickname).lower()) or (search_term.lower() in str(email).lower()):
                                    username = nickname + ' ' + email
                            elif user.type == 1:
                                name = user.facebook_user.name

                                if search_term.lower() in str(name).lower():
                                    username = name
                            else:
                                logging.debug('Usuario nativo!')
                                logging.debug('key de usuario: ' + str(user.key()))
                                
                                name = user.native_user.name
                                email = user.native_user.email

                                if (search_term.lower() in str(name).lower()) or (search_term.lower() in str(email).lower()):
                                    username = name + ' ' + email

                            if username:
                                search_result.append((str(username), str(user.key())))
                            
                template_values = {
                    'session_status': True,
                    'user': session['active_user'],
                    'searched_users': search_result,
                    'members': eval(self.request.get('last-members')),
                    'name': self.request.get('name'),
                    'last_search': str(search_result),
                    'last_members': self.request.get('last-members'),
                    'top_scorers': get_top_scorers(),
                    'top_users': get_top_users_global_ranking(),
                    'last_jackpot': get_last_jackpot()
                }
                
                render_template(self, 'create_competition_group.html', template_values)
            elif save:
                active_user = session['active_user']                
                name = self.request.get('name')
               
                new_group = CACompetitonGroup(name=name, privacy=False)
                new_group.put()
                
                active_user.groups.append(new_group.key())
                active_user.put()
                
                active_user_football_pools = CAFootballPool.all().filter("user ="******"privacy =", False).fetch(1000)
                
                for football_pool in active_user_football_pools:
                    if football_pool.payment:
                        members = new_group.members.fetch(10000)
                        
                        group_ranking = CAGroupRanking(football_pool=football_pool, group=new_group, rank=len(members))
                        group_ranking.put()
                
                members = eval(self.request.get('last-members'))
                
                for member in members:
                    member_key = Key(member[1])
                    user = CAUser.get(member_key)
                    
                    users = []
                    users.append(active_user.key())
                    users.append(user.key())
                    
                    request_membership = CARequestGroupMembership(users=users, status=False, group=new_group)
                    request_membership.put()
                    
                #self.redirect('/list/groups/ranking')
                competition_groups = CACompetitonGroup.get(active_user.groups)
                
                template_values = {
                    'session_status': True,
                    'user': session['active_user'],
                    'groups': competition_groups,
                    'pending_membership_requests': get_pending_membership_requests(active_user),
                    'top_scorers': get_top_scorers(),
                    'top_users': get_top_users_global_ranking(),
                    'last_jackpot': get_last_jackpot(),
                    'message': 'Se han enviado con éxito las invitaciones a los usuarios para formar parte del grupo.'
                }
                
                render_template(self, 'list_competition_groups_to_ranking.html', template_values)
        else:
            self.redirect('/')
Esempio n. 15
0
    def post(self):
        update_session_time()
        session = get_current_session()
        check_session_status()

        if session.is_active():
            comment_text = self.request.get("comment-text")
            selected_competition_group_key = Key(self.request.get("selected_group_key"))
            competition_group = CACompetitonGroup.get(selected_competition_group_key)

            google_time = datetime.datetime.today()
            delta = datetime.timedelta(minutes=270)
            comment_time = google_time - delta

            comment = CAGroupComment(
                group=competition_group, user=session["active_user"], comment=comment_text, date=comment_time
            )
            comment.put()

            group_ranking = CAGroupRanking.all().filter("group =", selected_competition_group_key).fetch(10000)

            active_user = session["active_user"]
            active_user_football_pools = active_user.football_pools

            active_user_football_pools_keys = []
            for football_pool in active_user_football_pools:
                active_user_football_pools_keys.append(football_pool.key())

            group_ranking_list = []

            for rank in group_ranking:
                if rank.football_pool.key() in active_user_football_pools_keys:
                    selected = True
                else:
                    selected = False

                if rank.football_pool.user.type == 0:
                    name = rank.football_pool.user.google_user.nickname()
                elif rank.football_pool.user.type == 1:
                    name = rank.football_pool.user.facebook_user.name
                else:
                    name = rank.football_pool.user.native_user.name

                group_ranking_list.append(
                    (
                        name,
                        rank.football_pool.name,
                        get_total_points(rank.football_pool),
                        selected,
                        rank.football_pool.key(),
                    )
                )

            comments = CAGroupComment.all().filter("group =", competition_group).fetch(10000)
            comments_info = []

            for comment in comments:
                if comment.user.type == 0:
                    name = comment.user.google_user.nickname()
                elif comment.user.type == 1:
                    name = comment.user.facebook_user.name
                else:
                    name = comment.user.native_user.name

                comments_info.append(
                    (
                        name,
                        str(comment.date.day)
                        + "/"
                        + str(comment.date.month)
                        + "/"
                        + str(comment.date.year)
                        + " "
                        + str(comment.date.hour)
                        + ":"
                        + str(comment.date.minute),
                        comment.comment,
                    )
                )

            template_values = {
                "session_status": True,
                "user": active_user,
                "competition_group_name": competition_group.name,
                "group_ranking": group_ranking_list,
                "top_scorers": get_top_scorers(),
                "top_users": get_top_users_global_ranking(),
                "last_jackpot": get_last_jackpot(),
                "comments": comments_info,
                "selected_group_key": self.request.get("selected_group_key"),
            }

            render_template(self, "ranking.html", template_values)
        else:
            self.redirect("/")
 def get(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
     
     if session.is_active():
         original_pool = CAFootballPool.all().filter("privacy =", True).fetch(1)[0]
         first_round_matches = original_pool.first_round_matches.fetch(18)
         
         group_a_teams = []
         group_b_teams = []
         group_c_teams = []
         
         ga_teams = Set()
         gb_teams = Set()
         gc_teams = Set()
         
         for match in first_round_matches:
             team_list = db.get(match.teams)
             
             if team_list[0].group.name == 'A':
                 group_a_teams.append((team_list[0].name, team_list[1].name))
                 ga_teams.add(team_list[0].name)
                 ga_teams.add(team_list[1].name)
             elif team_list[0].group.name == 'B':
                 group_b_teams.append((team_list[0].name, team_list[1].name))
                 gb_teams.add(team_list[0].name)
                 gb_teams.add(team_list[1].name)
             else:
                 group_c_teams.append((team_list[0].name, team_list[1].name))
                 gc_teams.add(team_list[0].name)
                 gc_teams.add(team_list[1].name)
                 
         a_teams = list(ga_teams)
         b_teams = list(gb_teams)
         c_teams = list(gc_teams)
         
         ga_teams = []
         gb_teams = []
         gc_teams = []
         
         for counter in range(0, 4):
             if counter % 2 == 1:
                 ga_teams.append((a_teams[counter], "odd"))
                 gb_teams.append((b_teams[counter], "odd"))
                 gc_teams.append((c_teams[counter], "odd"))
             else:
                 ga_teams.append((a_teams[counter], "pair"))
                 gb_teams.append((b_teams[counter], "pair"))
                 gc_teams.append((c_teams[counter], "pair"))
                 
         sandra_key = Key('ag5zfnR1cXVpbmllbGFjYXIOCxIGQ0FVc2VyGJqdAQw')
         christian_key = Key('ag5zfnR1cXVpbmllbGFjYXINCxIGQ0FVc2VyGNR1DA')
         mariel_key = Key('ag5zfnR1cXVpbmllbGFjYXIOCxIGQ0FVc2VyGIG0AQw')
         francisco_key = Key('ag5zfnR1cXVpbmllbGFjYXIOCxIGQ0FVc2VyGIbUAQw')
         
         ca_user_key = session['active_user'].key()
         
         special_user = False
         
         if ca_user_key == sandra_key or ca_user_key == christian_key or ca_user_key == mariel_key or ca_user_key == francisco_key:
             special_user = True
             
         template_values = {
             'session_status': True,
             'user': session['active_user'],
             'groups': [(group_a_teams, ga_teams, 'A'), (group_b_teams, gb_teams, 'B'), (group_c_teams, gc_teams, 'C')],
             'top_scorers': get_top_scorers(),
             'top_users': get_top_users_global_ranking(),
             'last_jackpot': get_last_jackpot(),
             'special_user': special_user
         }
             
         render_template(self, 'create_step1.html', template_values)
     else:
         self.redirect('/')
    def get(self):
        update_session_time()
        session = get_current_session()
        check_session_status()

        if session.is_active():
            selected = self.request.get("id")

            selected_football_pool = CAFootballPool.get(Key(selected))
            first_round_matches = selected_football_pool.first_round_matches

            ga_team_set = Set()
            gb_team_set = Set()
            gc_team_set = Set()

            for match in first_round_matches:
                team_list = db.get(match.teams)

                if team_list[0].group.name == "A":
                    ga_team_set.add(team_list[0].name)
                    ga_team_set.add(team_list[1].name)
                elif team_list[0].group.name == "B":
                    gb_team_set.add(team_list[0].name)
                    gb_team_set.add(team_list[1].name)
                else:
                    gc_team_set.add(team_list[0].name)
                    gc_team_set.add(team_list[1].name)

            a_teams = list(ga_team_set)
            b_teams = list(gb_team_set)
            c_teams = list(gc_team_set)

            ga_teams_info = []
            gb_teams_info = []
            gc_teams_info = []

            for counter in range(0, 4):
                if counter % 2 == 1:
                    ga_teams_info.append((a_teams[counter], "odd"))
                    gb_teams_info.append((b_teams[counter], "odd"))
                    gc_teams_info.append((c_teams[counter], "odd"))
                else:
                    ga_teams_info.append((a_teams[counter], "pair"))
                    gb_teams_info.append((b_teams[counter], "pair"))
                    gc_teams_info.append((c_teams[counter], "pair"))

            ga_results = []
            gb_results = []
            gc_results = []

            for match in first_round_matches:
                match_info = []
                team_list = db.get(match.teams)

                match_info.append(team_list[0].name)
                match_info.append(str(match.goals_team1))
                match_info.append(str(match.goals_team2))
                match_info.append(team_list[1].name)

                if team_list[0].group.name == "A":
                    ga_results.append(match_info)
                elif team_list[0].group.name == "B":
                    gb_results.append(match_info)
                else:
                    gc_results.append(match_info)

            second_round_matches = selected_football_pool.second_round_matches.fetch(8)

            quarter_finals_matches = []

            for i in range(0, 4):
                match = second_round_matches[i]
                match_info = []
                team_list = db.get(match.teams)

                match_info.append(team_list[0].name)
                match_info.append(str(match.goals_team1))
                match_info.append(str(match.goals_team2))
                match_info.append(team_list[1].name)
                match_info.append(str(i + 1))

                quarter_finals_matches.append(match_info)

            semi_final_matches = []

            for i in range(4, 6):
                match = second_round_matches[i]
                match_info = []
                team_list = db.get(match.teams)

                match_info.append(team_list[0].name)
                match_info.append(str(match.goals_team1))
                match_info.append(str(match.goals_team2))
                match_info.append(team_list[1].name)
                match_info.append(str(i - 3))

                semi_final_matches.append(match_info)

            match = second_round_matches[6]
            third_fourth_match = []
            team_list = db.get(match.teams)

            third_fourth_match.append(team_list[0].name)
            third_fourth_match.append(str(match.goals_team1))
            third_fourth_match.append(str(match.goals_team2))
            third_fourth_match.append(team_list[1].name)

            match = second_round_matches[7]
            final_match = []
            team_list = db.get(match.teams)

            final_match.append(team_list[0].name)
            final_match.append(str(match.goals_team1))
            final_match.append(str(match.goals_team2))
            final_match.append(team_list[1].name)

            template_values = {
                "session_status": True,
                "user": session["active_user"],
                "name": selected_football_pool.name,
                "groups": [
                    (ga_results, ga_teams_info, "A"),
                    (gb_results, gb_teams_info, "B"),
                    (gc_results, gc_teams_info, "C"),
                ],
                "quarter_finals_matches": quarter_finals_matches,
                "semi_final_matches": semi_final_matches,
                "third_fourth_match": third_fourth_match,
                "final_match": final_match,
                "top_scorers": get_top_scorers(),
                "top_users": get_top_users_global_ranking(),
                "last_jackpot": get_last_jackpot(),
            }

            render_template(self, "view_football_pool.html", template_values)
        else:
            self.redirect("/")
    def post(self):
        update_session_time()
        session = get_current_session()
        check_session_status()
        
        if session.is_active():
            selected_football_pool_key = Key(self.request.get('football-pool-key'))
                
            selected_football_pool = CAFootballPool.get(selected_football_pool_key)
            first_round_matches = selected_football_pool.first_round_matches
            final_matches = []
            change_first_round = False
            
            for match in first_round_matches:
                team_list = db.get(match.teams)
                match_list = []
                
                key0 = team_list[0].name[:3]
                key1 = team_list[1].name[:3]
                
                final_key1 = key0 + '-' + key1 + '-g1'
                final_key2 = key0 + '-' + key1 + '-g2'

                if (match.goals_team1 != int(self.request.get(final_key1))) or (match.goals_team2 != int(self.request.get(final_key2))):
                    change_first_round = True
                                
                match_list.append(final_key1)
                match_list.append(self.request.get(final_key1))
                match_list.append(final_key2)
                match_list.append(self.request.get(final_key2))
                
                final_matches.append(match_list)
            
            if change_first_round:
                first_round_winners = eval(self.request.get('first-round-winners'))
                quarter_finals_teams = []
                
                counter = 1
                for winners in first_round_winners:
                    initials = winners[1].partition('-')
                    team_names = []
                    team_names.append(get_team_whole_name(initials[0]))
                    team_names.append(get_team_whole_name(initials[2]))
                    team_names.append(counter)
                    quarter_finals_teams.append(team_names)
                    counter += 1
                
                template_values = {
                    'session_status': True,
                    'user': session['active_user'],
                    'football_pool_key': selected_football_pool.key(),
                    'first_round_matches': str(final_matches),
                    'quarter_finals_teams': quarter_finals_teams,
                    'top_scorers': get_top_scorers(),
                    'top_users': get_top_users_global_ranking(),
                    'last_jackpot': get_last_jackpot()
                }
                
                render_template(self, 'edit_step2_1.html', template_values)
            else:
                second_round_matches = selected_football_pool.second_round_matches.fetch(8)
                    
                quarter_finals_matches = []
                
                for i in range(0, 4):
                    match = second_round_matches[i]
                    match_info = []
                    team_list = db.get(match.teams)
                    
                    match_info.append(team_list[0].name)
                    match_info.append(str(match.goals_team1))
                    match_info.append(str(match.goals_team2))
                    match_info.append(team_list[1].name)
                    match_info.append(str(i + 1))
                    
                    quarter_finals_matches.append(match_info)
                    
                semi_final_matches = []
                    
                for i in range(4, 6):
                    match = second_round_matches[i]
                    match_info = []
                    team_list = db.get(match.teams)
                    
                    match_info.append(team_list[0].name)
                    match_info.append(str(match.goals_team1))
                    match_info.append(str(match.goals_team2))
                    match_info.append(team_list[1].name)
                    match_info.append(str(i - 3))
                    
                    semi_final_matches.append(match_info)
                    
                match = second_round_matches[6]
                third_fourth_match = []
                team_list = db.get(match.teams)
                   
                third_fourth_match.append(team_list[0].name)
                third_fourth_match.append(str(match.goals_team1))
                third_fourth_match.append(str(match.goals_team2))
                third_fourth_match.append(team_list[1].name)
                
                match = second_round_matches[7]
                final_match = []
                team_list = db.get(match.teams)
                   
                final_match.append(team_list[0].name)
                final_match.append(str(match.goals_team1))
                final_match.append(str(match.goals_team2))
                final_match.append(team_list[1].name)
                
                template_values = {
                    'session_status': True,
                    'user': session['active_user'],
                    'football_pool_key': selected_football_pool.key(),
                    'first_round_matches': str([]),
                    'quarter_finals_matches': quarter_finals_matches,
                    'semi_final_matches': semi_final_matches,
                    'third_fourth_match': third_fourth_match,
                    'final_match': final_match,
                    'top_scorers': get_top_scorers(),
                    'top_users': get_top_users_global_ranking(),
                    'last_jackpot': get_last_jackpot()
                }
            
                render_template(self, 'edit_step2_2.html', template_values)
        else:
            self.redirect('/')
 def post(self):
     update_session_time()
     session = get_current_session()
     check_session_status()
         
     if session.is_active():
         selected = self.request.get('selected_football_pool')
         
         view = self.request.get('view')
         pay = self.request.get('pay')
         edit = self.request.get('edit')
         
         if selected != "default":
             selected_football_pool_key = Key(selected)
             
             if view:
                 selected_football_pool = CAFootballPool.get(selected_football_pool_key)
                 first_round_matches = selected_football_pool.first_round_matches
                 
                 ga_team_set = Set()
                 gb_team_set = Set()
                 gc_team_set = Set()
                 
                 for match in first_round_matches:
                     team_list = db.get(match.teams)
                     
                     if team_list[0].group.name == 'A':
                         ga_team_set.add(team_list[0].name)
                         ga_team_set.add(team_list[1].name)
                     elif team_list[0].group.name == 'B':
                         gb_team_set.add(team_list[0].name)
                         gb_team_set.add(team_list[1].name)
                     else:
                         gc_team_set.add(team_list[0].name)
                         gc_team_set.add(team_list[1].name)
                         
                 a_teams = list(ga_team_set)
                 b_teams = list(gb_team_set)
                 c_teams = list(gc_team_set)
                 
                 ga_teams_info = []
                 gb_teams_info = []
                 gc_teams_info = []
                 
                 for counter in range(0, 4):
                     if counter % 2 == 1:
                         ga_teams_info.append((a_teams[counter], "odd"))
                         gb_teams_info.append((b_teams[counter], "odd"))
                         gc_teams_info.append((c_teams[counter], "odd"))
                     else:
                         ga_teams_info.append((a_teams[counter], "pair"))
                         gb_teams_info.append((b_teams[counter], "pair"))
                         gc_teams_info.append((c_teams[counter], "pair"))
                         
                 ga_results = []
                 gb_results = []
                 gc_results = []
                 
                 for match in first_round_matches:
                     match_info = []
                     team_list = db.get(match.teams)
                     
                     match_info.append(team_list[0].name)
                     match_info.append(str(match.goals_team1))
                     match_info.append(str(match.goals_team2))
                     match_info.append(team_list[1].name)
                     
                     if team_list[0].group.name == 'A':
                         ga_results.append(match_info)
                     elif team_list[0].group.name == 'B':
                         gb_results.append(match_info)
                     else:
                         gc_results.append(match_info)
                         
                 second_round_matches = selected_football_pool.second_round_matches.fetch(8)
                 
                 quarter_finals_matches = []
                 
                 for i in range(0, 4):
                     match = second_round_matches[i]
                     match_info = []
                     team_list = db.get(match.teams)
                     
                     match_info.append(team_list[0].name)
                     match_info.append(str(match.goals_team1))
                     match_info.append(str(match.goals_team2))
                     match_info.append(team_list[1].name)
                     match_info.append(str(i + 1))
                     
                     quarter_finals_matches.append(match_info)
                     
                 semi_final_matches = []
                     
                 for i in range(4, 6):
                     match = second_round_matches[i]
                     match_info = []
                     team_list = db.get(match.teams)
                     
                     match_info.append(team_list[0].name)
                     match_info.append(str(match.goals_team1))
                     match_info.append(str(match.goals_team2))
                     match_info.append(team_list[1].name)
                     match_info.append(str(i - 3))
                     
                     semi_final_matches.append(match_info)
                     
                 match = second_round_matches[6]
                 third_fourth_match = []
                 team_list = db.get(match.teams)
                    
                 third_fourth_match.append(team_list[0].name)
                 third_fourth_match.append(str(match.goals_team1))
                 third_fourth_match.append(str(match.goals_team2))
                 third_fourth_match.append(team_list[1].name)
                 
                 match = second_round_matches[7]
                 final_match = []
                 team_list = db.get(match.teams)
                    
                 final_match.append(team_list[0].name)
                 final_match.append(str(match.goals_team1))
                 final_match.append(str(match.goals_team2))
                 final_match.append(team_list[1].name)
                 
                 template_values = {
                     'session_status': True,
                     'user': session['active_user'],
                     'name': selected_football_pool.name,
                     'groups': [(ga_results, ga_teams_info, 'A'), (gb_results, gb_teams_info, 'B'), (gc_results, gc_teams_info, 'C')],
                     'quarter_finals_matches': quarter_finals_matches,
                     'semi_final_matches': semi_final_matches,
                     'third_fourth_match': third_fourth_match,
                     'final_match': final_match,
                     'top_scorers': get_top_scorers(),
                     'top_users': get_top_users_global_ranking(),
                     'last_jackpot': get_last_jackpot()
                 } 
                     
                 render_template(self, 'view_football_pool.html', template_values)
             elif pay:
                 selected_football_pool = CAFootballPool.get(Key(self.request.get('selected_football_pool')))
                 
                 if selected_football_pool.payment:
                     active_user = session['active_user']
                 
                     active_user_football_pools = CAFootballPool.all().filter("user ="******"privacy =", False).fetch(1000)
                     
                     template_values = {
                         'session_status': True,
                         'user': session['active_user'],
                         'football_pools': active_user_football_pools,
                         'message':'Esta quiniela ya fue pagada',
                         'top_scorers': get_top_scorers(),
                         'top_users': get_top_users_global_ranking(),
                         'last_jackpot': get_last_jackpot()
                     } 
                     
                     render_template(self, 'list_football_pools_to_pay.html', template_values)
                 else:
                     template_values = {
                         'session_status': True,
                         'user': session['active_user'],
                         'selected_football_pool_key': self.request.get('selected_football_pool'),
                         'top_scorers': get_top_scorers(),
                         'top_users': get_top_users_global_ranking(),
                         'last_jackpot': get_last_jackpot(),
                         'selected_user': '',
                         'searched_users': []
                     }
                     
                     render_template(self, 'pay_football_pool.html', template_values)
             elif edit:
                 selected_football_pool = CAFootballPool.get(selected_football_pool_key)
                 first_round_matches = selected_football_pool.first_round_matches
                 
                 ga_team_set = Set()
                 gb_team_set = Set()
                 gc_team_set = Set()
                     
                 for match in first_round_matches:
                     team_list = db.get(match.teams)
                         
                     if team_list[0].group.name == 'A':
                         ga_team_set.add(team_list[0].name)
                         ga_team_set.add(team_list[1].name)
                     elif team_list[0].group.name == 'B':
                         gb_team_set.add(team_list[0].name)
                         gb_team_set.add(team_list[1].name)
                     else:
                         gc_team_set.add(team_list[0].name)
                         gc_team_set.add(team_list[1].name)
                             
                 a_teams = list(ga_team_set)
                 b_teams = list(gb_team_set)
                 c_teams = list(gc_team_set)
                     
                 ga_teams_info = []
                 gb_teams_info = []
                 gc_teams_info = []
                     
                 for counter in range(0, 4):
                     if counter % 2 == 1:
                         ga_teams_info.append((a_teams[counter], "odd"))
                         gb_teams_info.append((b_teams[counter], "odd"))
                         gc_teams_info.append((c_teams[counter], "odd"))
                     else:
                         ga_teams_info.append((a_teams[counter], "pair"))
                         gb_teams_info.append((b_teams[counter], "pair"))
                         gc_teams_info.append((c_teams[counter], "pair"))
                             
                 ga_results = []
                 gb_results = []
                 gc_results = []
                     
                 for match in first_round_matches:
                     match_info = []
                     team_list = db.get(match.teams)
                         
                     match_info.append(team_list[0].name)
                     match_info.append(str(match.goals_team1))
                     match_info.append(str(match.goals_team2))
                     match_info.append(team_list[1].name)
                         
                     if team_list[0].group.name == 'A':
                         ga_results.append(match_info)
                     elif team_list[0].group.name == 'B':
                         gb_results.append(match_info)
                     else:
                         gc_results.append(match_info)
                         
                 template_values = {
                     'session_status': True,
                     'user': session['active_user'],
                     'name': selected_football_pool.name,
                     'groups': [(ga_results, ga_teams_info, 'A'), (gb_results, gb_teams_info, 'B'), (gc_results, gc_teams_info, 'C')],
                     'football_pool_key': selected_football_pool.key(),
                     'top_scorers': get_top_scorers(),
                     'top_users': get_top_users_global_ranking(),
                     'last_jackpot': get_last_jackpot()
                 } 
                         
                 render_template(self, 'edit_step1.html', template_values)
         else:
             if view or edit:
                 self.redirect('/list/football-pools/view')
             elif pay:
                 self.redirect('/list/football-pools/pay')
     else:
         self.redirect('/')
Esempio n. 20
0
    def get(self):
        session = get_current_session()

        check_session_status()
        upcomming_matches = get_upcomming_matches()
        upcomming_matches_info = []

        for match in upcomming_matches:
            team_list = db.get(match.teams)

            upcomming_matches_info.append((team_list[0].name, team_list[1].name, str(match.date)))

        copa_america = CAFootballPool.all().filter("privacy =", True).fetch(1)[0]

        copa_america_first_round_matches = copa_america.first_round_matches

        ga_team_set = Set()
        gb_team_set = Set()
        gc_team_set = Set()

        for match in copa_america_first_round_matches:
            team_list = db.get(match.teams)

            if team_list[0].group.name == "A":
                ga_team_set.add(team_list[0].name)
                ga_team_set.add(team_list[1].name)
            elif team_list[0].group.name == "B":
                gb_team_set.add(team_list[0].name)
                gb_team_set.add(team_list[1].name)
            else:
                gc_team_set.add(team_list[0].name)
                gc_team_set.add(team_list[1].name)

        a_teams = list(ga_team_set)
        b_teams = list(gb_team_set)
        c_teams = list(gc_team_set)

        ga_teams_info = []
        gb_teams_info = []
        gc_teams_info = []

        for counter in range(0, 4):
            if counter % 2 == 1:
                ga_teams_info.append((a_teams[counter], "odd"))
                gb_teams_info.append((b_teams[counter], "odd"))
                gc_teams_info.append((c_teams[counter], "odd"))
            else:
                ga_teams_info.append((a_teams[counter], "pair"))
                gb_teams_info.append((b_teams[counter], "pair"))
                gc_teams_info.append((c_teams[counter], "pair"))

        ga_results = []
        gb_results = []
        gc_results = []

        for match in copa_america_first_round_matches:
            match_info = []
            team_list = db.get(match.teams)

            match_info.append(team_list[0].name)
            match_info.append(str(match.goals_team1))
            match_info.append(str(match.goals_team2))
            match_info.append(team_list[1].name)

            if team_list[0].group.name == "A":
                ga_results.append(match_info)
            elif team_list[0].group.name == "B":
                gb_results.append(match_info)
            else:
                gc_results.append(match_info)

        second_round_matches = copa_america.second_round_matches.fetch(8)

        quarter_finals_matches = []

        for i in range(0, 4):
            match = second_round_matches[i]
            match_info = []
            team_list = db.get(match.teams)

            if team_list:
                match_info.append(team_list[0].name)
                match_info.append(str(match.goals_team1))
                match_info.append(str(match.goals_team2))
                match_info.append(team_list[1].name)
                match_info.append(str(i + 1))
            else:
                match_info.append("?")
                match_info.append("")
                match_info.append("")
                match_info.append("?")
                match_info.append(str(i + 1))

            quarter_finals_matches.append(match_info)

        semi_final_matches = []

        for i in range(4, 6):
            match = second_round_matches[i]
            match_info = []
            team_list = db.get(match.teams)

            if team_list:
                match_info.append(team_list[0].name)
                match_info.append(str(match.goals_team1))
                match_info.append(str(match.goals_team2))
                match_info.append(team_list[1].name)
                match_info.append(str(i - 3))
            else:
                match_info.append("?")
                match_info.append("")
                match_info.append("")
                match_info.append("?")
                match_info.append(str(i - 3))

            semi_final_matches.append(match_info)

        match = second_round_matches[6]
        third_fourth_match = []
        team_list = db.get(match.teams)

        if team_list:
            third_fourth_match.append(team_list[0].name)
            third_fourth_match.append(str(match.goals_team1))
            third_fourth_match.append(str(match.goals_team2))
            third_fourth_match.append(team_list[1].name)
        else:
            third_fourth_match.append("?")
            third_fourth_match.append("")
            third_fourth_match.append("")
            third_fourth_match.append("?")

        match = second_round_matches[7]
        final_match = []
        team_list = db.get(match.teams)

        if team_list:
            final_match.append(team_list[0].name)
            final_match.append(str(match.goals_team1))
            final_match.append(str(match.goals_team2))
            final_match.append(team_list[1].name)
        else:
            final_match.append("?")
            final_match.append("")
            final_match.append("")
            final_match.append("?")

        if session.is_active():

            template_values = {
                "session_status": True,
                "user": session["active_user"],
                "upcomming_matches_info": upcomming_matches_info,
                "name": copa_america.name,
                "groups": [
                    (ga_results, ga_teams_info, "A"),
                    (gb_results, gb_teams_info, "B"),
                    (gc_results, gc_teams_info, "C"),
                ],
                "quarter_finals_matches": quarter_finals_matches,
                "semi_final_matches": semi_final_matches,
                "third_fourth_match": third_fourth_match,
                "final_match": final_match,
                "top_scorers": get_top_scorers(),
                "top_users": get_top_users_global_ranking(),
                "last_jackpot": get_last_jackpot(),
            }
        else:
            template_values = {
                "session_status": False,
                "upcomming_matches_info": upcomming_matches_info,
                "name": copa_america.name,
                "groups": [
                    (ga_results, ga_teams_info, "A"),
                    (gb_results, gb_teams_info, "B"),
                    (gc_results, gc_teams_info, "C"),
                ],
                "quarter_finals_matches": quarter_finals_matches,
                "semi_final_matches": semi_final_matches,
                "third_fourth_match": third_fourth_match,
                "final_match": final_match,
                "top_scorers": get_top_scorers(),
                "top_users": get_top_users_global_ranking(),
                "last_jackpot": get_last_jackpot(),
            }

        render_template(self, "copa_america.html", template_values)
    def post(self):
        update_session_time()
        session = get_current_session()
        check_session_status()
            
        if session.is_active():
            search_user = self.request.get('search_user')
            save = self.request.get('save')
            
            if search_user:
                active_user = session['active_user']
                
                search_term = self.request.get('search')
                search_result = []
                selected_competition_group_key = Key(self.request.get('selected-football-pool'))
                competition_group = CACompetitonGroup.get(selected_competition_group_key)
                members = competition_group.members.fetch(10000)
                members_keys = []
                
                for member in members:
                    members_keys.append(member.key())
                
                if search_term:
                    users = CAUser.all().fetch(10000)
                    
                    for user in users:
                        if active_user.key() != user.key():
                            if user.key() not in members_keys:
                                username = []
                                
                                if user.type == 0:
                                    nickname = user.google_user.nickname()
                                    email = user.google_user.email()
                                    
                                    if (search_term.lower() in str(nickname).lower()) or (search_term.lower() in str(email).lower()):
                                        username = nickname +" "+email
                                elif user.type == 1:
                                    name = user.facebook_user.name
                                    
                                    if search_term.lower() in str(name).lower():
                                        username = name
                                else:
                                    name = user.native_user.name
                                    email = user.native_user.email
                                    
                                    if (search_term.lower() in str(name).lower()) or (search_term.lower() in str(email).lower()):
                                        username = name+" "+email
                            
                                if username:
                                    search_result.append((str(username), str(user.key())))
                            
                template_values = {
                    'session_status': True,
                    'user': session['active_user'],
                    'searched_users': search_result,
                    'members': eval(self.request.get('last-members')),
                    'name': self.request.get('name'),
                    'last_search': str(search_result),
                    'last_members': self.request.get('last-members'),
                    'top_scorers': get_top_scorers(),
                    'top_users': get_top_users_global_ranking(),
                    'last_jackpot': get_last_jackpot(),
                    'selected_football_pool': self.request.get('selected-football-pool')
                }
                
                render_template(self, 'edit_competition_group.html', template_values)
            elif save:
                active_user = session['active_user']                
                name = self.request.get('name')
                
                selected_competition_group_key = Key(self.request.get('selected-football-pool'))
                competition_group = CACompetitonGroup.get(selected_competition_group_key)
                
                if competition_group.name != name:
                    competition_group.name = name
                    competition_group.put()
               
#                new_group = CACompetitonGroup(name=name, privacy=False)
#                new_group.put()
#                
#                active_user.groups.append(new_group.key())
#                active_user.put()
                
#                active_user_football_pools = CAFootballPool.all().filter("user ="******"privacy =", False).fetch(1000)
#                
#                for football_pool in active_user_football_pools:
#                    if football_pool.payment:
#                        members = new_group.members.fetch(10000)
#                        
#                        group_ranking = CAGroupRanking(football_pool=football_pool, group=new_group, rank=len(members))
#                        group_ranking.put()
                
                members = eval(self.request.get('last-members'))
                
                for member in members:
                    if member[2]:
                        member_key = Key(member[1])
                        user = CAUser.get(member_key)
                        
                        users = []
                        users.append(active_user.key())
                        users.append(user.key())
                        
                        request_membership = CARequestGroupMembership(users=users, status=False, group=competition_group)
                        request_membership.put()
                    
                self.redirect('/list/groups/ranking')
        else:
            self.redirect('/')