def get(self): rnd = self.request.get('round') _id = self.request.get('id') name = '' ret = '[]' if rnd in ('speed', 'accuracy'): ind = Individual.query(Individual.assigned_id == _id, Individual.year == YEAR) if ind.count() > 0: ind = ind.fetch()[0] name = ind.name + '|' + Team.get_by_id(ind.team).name if rnd == 'speed': ret = ind.speed_scores else: ret = ind.accuracy_scores else: team = Team.query(Team.assigned_id == _id) if team.count() > 0: team = team.fetch()[0] name = team.name if rnd == 'team': ret = team.team_scores else: if team.guts_scores is None: ret = [] else: ret = team.guts_scores self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({ 'scores': ret, 'name': name }))
def get(self): team = Team.get_by_id(int(self.request.get('id'))) team.name = self.request.get('name') team.put() self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({'success': True}))
def get(self): teams = {} individuals = [] # Create and insert a record # for this registration. user = self.auth.get_user_by_session()['user_id'] query = Individual.query(Individual.user == user) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append(member.serialize_full()) else: teams[member.team] = { 'members': [member.serialize_full()] } else: individuals.append(member.serialize_full()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name teams[team_id]['id'] = int(team_id) teams[team_id]['paid'] = record.paid teams[team_id]['year'] = record.year teams[team_id]['guts_scores'] = parse_or_none(record.guts_scores) teams[team_id]['team_scores'] = parse_or_none(record.team_scores) # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({ 'teams': teams, 'individuals': individuals }))
def get(self): rnd = self.request.get('round') _id = self.request.get('id') name = '' ret = '[]' if rnd in ('speed', 'accuracy'): ind = Individual.query(Individual.assigned_id == _id, Individual.year == YEAR) if ind.count() > 0: ind = ind.fetch()[0] name = ind.name + '|' + Team.get_by_id(ind.team).name if rnd == 'speed': ret = ind.speed_scores else: ret = ind.accuracy_scores else: team = Team.query(Team.assigned_id == _id) if team.count() > 0: team = team.fetch()[0] name = team.name if rnd == 'team': ret = team.team_scores else: if team.guts_scores is None: ret = [] else: ret = team.guts_scores self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({'scores': ret, 'name': name}))
def get(self): teams = {} individuals = [] # Create and insert a record # for this registration. user = self.auth.get_user_by_session()['user_id'] query = Individual.query(Individual.user == user) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append( member.serialize_full()) else: teams[member.team] = {'members': [member.serialize_full()]} else: individuals.append(member.serialize_full()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name teams[team_id]['id'] = int(team_id) teams[team_id]['paid'] = record.paid teams[team_id]['year'] = record.year teams[team_id]['guts_scores'] = parse_or_none(record.guts_scores) teams[team_id]['team_scores'] = parse_or_none(record.team_scores) # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write( json.dumps({ 'teams': teams, 'individuals': individuals }))
def get(self): old_id = int(self.request.get('primary_id')) new_id = self.request.get('assigned_id') team = Team.get_by_id(old_id) team.assigned_id = new_id team.put() self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({'success': True}))
def get(self): users = self.user_model.query(self.user_model.team_updated >= ( datetime.datetime.today() - datetime.timedelta(hours=1))).fetch() for user in users: teams = {} individuals = [] query = Individual.query(Individual.user == user.key.id(), Individual.year == YEAR) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append( member.serialize()) else: teams[member.team] = {'members': [member.serialize()]} else: individuals.append(member.serialize()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name values = teams.values() body = "" for team in values: body += """ %s %s %s %s %s """ % (team['name'], team['members'][0], team['members'][1], team['members'][2], team['members'][3]) if len(individuals) > 0: body += """ Individuals """ for individual in individuals: body += individual + '\n' mail.send_mail( sender= 'Exeter Math Club Competition <*****@*****.**>', to=user.auth_ids[0], subject='EMCC Team Information Change', body="""Hi, This email is to confirm that you have made changes to your registered teams and the list of teams and individuals registered is now: %s Best, Exeter Math Club Competition""" % (body, ))
def get(self): users = self.user_model.query(self.user_model.team_updated >= (datetime.datetime.today() - datetime.timedelta(hours=1))).fetch() for user in users: teams = {} individuals = [] query = Individual.query(Individual.user == user.key.id(), Individual.year == YEAR) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append(member.serialize()) else: teams[member.team] = { 'members': [member.serialize()] } else: individuals.append(member.serialize()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name values = teams.values() body = "" for team in values: body += """ %s %s %s %s %s """ % (team['name'], team['members'][0], team['members'][1], team['members'][2], team['members'][3]) if len(individuals) > 0: body += """ Individuals """ for individual in individuals: body += individual + '\n' mail.send_mail(sender='Exeter Math Club Competition <*****@*****.**>', to=user.auth_ids[0], subject='EMCC Team Information Change', body="""Hi, This email is to confirm that you have made changes to your registered teams and the list of teams and individuals registered is now: %s Best, Exeter Math Club Competition""" % (body,))
def get(self): teams = {} individuals = [] # Query all users registered this year. query = Individual.query(Individual.year == YEAR) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append(member.serialize()) else: teams[member.team] = { 'members': [member.serialize()] } else: individuals.append(member.serialize()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name teams[team_id]['id'] = int(team_id) teams[team_id]['assigned_id'] = record.assigned_id teams[team_id]['paid'] = record.paid teams[team_id]['user'] = record.user users_query = User.query() users = {} for user in users_query: users[user.key.id()] = user.auth_ids[0] # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({ 'teams': teams, 'individuals': individuals, 'users': users }))
def post(self): # Create and insert a record # for this registration. user_id = int(self.auth.get_user_by_session()['user_id']) query = Individual.query(Individual.user == user_id, Individual.year == YEAR) for member in query: member.key.delete() individuals = json.loads(self.request.get('individuals')) for individual in individuals: record = Individual( name = individual['name'], team = individual['team'], user = user_id, paid = (individual['paid'] if 'paid' in individual else False), year = YEAR ) record.put() teams = json.loads(self.request.get('teams')) for team in teams: print team record = Team.get_by_id(team['id']) record.name = team['name'] record.put() user = self.user_model.get_by_id(user_id) user.refresh() user.put() # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({ 'success': True }))
def get(self): teams = {} individuals = [] # Query all users registered this year. query = Individual.query(Individual.year == YEAR) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append(member.serialize()) else: teams[member.team] = {'members': [member.serialize()]} else: individuals.append(member.serialize()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name teams[team_id]['id'] = int(team_id) teams[team_id]['assigned_id'] = record.assigned_id teams[team_id]['paid'] = record.paid teams[team_id]['user'] = record.user users_query = User.query() users = {} for user in users_query: users[user.key.id()] = user.auth_ids[0] # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write( json.dumps({ 'teams': teams, 'individuals': individuals, 'users': users }))
def get(self): teams = {} individuals = [] # Create and insert a record # for this registration. user_dict = self.auth.get_user_by_session() if user_dict: user = user_dict['user_id'] query = Individual.query(Individual.user == user, Individual.year == YEAR) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append( member.serialize()) else: teams[member.team] = {'members': [member.serialize()]} else: individuals.append(member.serialize()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name teams[team_id]['id'] = int(team_id) teams[team_id]['paid'] = record.paid # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write( json.dumps({ 'teams': teams, 'individuals': individuals })) else: self.abort(403)
def post(self): # Create and insert a record # for this registration. user_id = int(self.auth.get_user_by_session()['user_id']) query = Individual.query(Individual.user == user_id, Individual.year == YEAR) for member in query: member.key.delete() individuals = json.loads(self.request.get('individuals')) for individual in individuals: record = Individual( name=individual['name'], team=individual['team'], user=user_id, paid=(individual['paid'] if 'paid' in individual else False), year=YEAR) record.put() teams = json.loads(self.request.get('teams')) for team in teams: print team record = Team.get_by_id(team['id']) record.name = team['name'] record.put() user = self.user_model.get_by_id(user_id) user.refresh() user.put() # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({'success': True}))
def get(self): teams = {} individuals = [] # Create and insert a record # for this registration. user_dict = self.auth.get_user_by_session() if user_dict: user = user_dict['user_id'] query = Individual.query(Individual.user == user, Individual.year == YEAR) for member in query: if member.team != -1: if member.team in teams: teams[member.team]['members'].append(member.serialize()) else: teams[member.team] = { 'members': [member.serialize()] } else: individuals.append(member.serialize()) for team_id in teams: record = Team.get_by_id(team_id) teams[team_id]['name'] = record.name teams[team_id]['id'] = int(team_id) teams[team_id]['paid'] = record.paid # Inform the client of success. self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps({ 'teams': teams, 'individuals': individuals })) else: self.abort(403)