def post(self): disable = 1 #list to hold IDs of matched tables without teams no_team_tables = [] #get tables that match tot_ts = Table.gql("") #add the beginning count total_tables = tot_ts.count(2000) ts = Table.gql("WHERE name IN('SVB', :1)", u'SV Böblingen D1') #add the number affected with SVB and SV B total_bad = ts.count(2000) deletecounter = 0 for t in ts: teams = Team.gql("WHERE table = :1", t) if teams.count() == 0: #do the delete thing helperfunctions.deletetable(t.key()) deletecounter += 1 #add the number of deleted tables delete_tables = deletecounter post_ts = Table.gql("WHERE name IN('SVB', :1)", u'SV Böblingen D1') #add the number remainig after the delete operation remaining_tables = post_ts.count(2000) template_values = { 'total_tables': total_tables, 'total_bad': total_bad, 'delete_tables': delete_tables, 'remaining_tables': remaining_tables, 'disable': disable } path = os.path.join(os.path.dirname(__file__), 'admin/admin.html') self.response.out.write(template.render(path, template_values))
def get(self): tab = None u = None table_name = self.request.get('name', default_value="Unnamed table") try: points_for_win = int(self.request.get('points_for_win')) except: points_for_win = 3 try: points_for_score_draw = int(self.request.get('points_for_score_draw')) except: points_for_score_draw = 1 try: points_for_draw = int(self.request.get('points_for_draw')) except: points_for_draw = 1 try: points_for_lose = int(self.request.get('points_for_lose')) except: points_for_lose = 0 if users.get_current_user() == None: if 'sportablesuser' in self.request.cookies: u = User.gql("WHERE tempusername = :1", self.request.cookies['sportablesuser']) else: u = User.gql("WHERE username = :1", users.get_current_user()) if u != None: if u.count() == 1: for p in u: table = Table(user=p, name=table_name, points_for_win=points_for_win, points_for_score_draw=points_for_score_draw, points_for_draw=points_for_draw, points_for_lose=points_for_lose, viewable=True).put() tab = table.id() self.redirect('/getteams?table_name=' + str(tab)) else: logging.warning("user has a google or temp account but has no User entity") self.redirect('/') else: logging.warning("user has neither logged in with a google account or a set a cookie") self.redirect('/')