def get(self, event_key): datafeed = DatafeedFMSAPI('v2.0', save_response=True) event = Event.get_by_id(event_key) awards = datafeed.getAwards(event) if event and event.remap_teams: EventHelper.remapteams_awards(awards, event.remap_teams) new_awards = AwardManipulator.createOrUpdate(awards) if new_awards is None: new_awards = [] elif type(new_awards) != list: new_awards = [new_awards] # create EventTeams team_ids = set() for award in new_awards: for team in award.team_list: team_ids.add(team.id()) teams = TeamManipulator.createOrUpdate([ Team(id=team_id, team_number=int(team_id[3:])) for team_id in team_ids ]) if teams: if type(teams) is not list: teams = [teams] event_teams = EventTeamManipulator.createOrUpdate([ EventTeam(id=event_key + "_" + team.key.id(), event=event.key, team=team.key, year=event.year) for team in teams ]) template_values = { 'awards': new_awards, } if 'X-Appengine-Taskname' not in self.request.headers: # Only write out if not in taskqueue path = os.path.join( os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html') self.response.out.write(template.render(path, template_values))
def get(self, event_key): datafeed = DatafeedFMSAPI('v2.0', save_response=True) event = Event.get_by_id(event_key) awards = datafeed.getAwards(event) if event and event.remap_teams: EventHelper.remapteams_awards(awards, event.remap_teams) new_awards = AwardManipulator.createOrUpdate(awards) if new_awards is None: new_awards = [] elif type(new_awards) != list: new_awards = [new_awards] # create EventTeams team_ids = set() for award in new_awards: for team in award.team_list: team_ids.add(team.id()) teams = TeamManipulator.createOrUpdate([Team( id=team_id, team_number=int(team_id[3:])) for team_id in team_ids]) if teams: if type(teams) is not list: teams = [teams] event_teams = EventTeamManipulator.createOrUpdate([EventTeam( id=event_key + "_" + team.key.id(), event=event.key, team=team.key, year=event.year) for team in teams]) template_values = { 'awards': new_awards, } if 'X-Appengine-Taskname' not in self.request.headers: # Only write out if not in taskqueue path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html') self.response.out.write(template.render(path, template_values))
def get(self, event_key): datafeed = DatafeedFMSAPI('v2.0') event = Event.get_by_id(event_key) new_awards = AwardManipulator.createOrUpdate(datafeed.getAwards(event)) if new_awards is None: new_awards = [] elif type(new_awards) != list: new_awards = [new_awards] # create EventTeams team_ids = set() for award in new_awards: for team in award.team_list: team_ids.add(team.id()) teams = TeamManipulator.createOrUpdate([ Team(id=team_id, team_number=int(team_id[3:])) for team_id in team_ids ]) if teams: if type(teams) is not list: teams = [teams] event_teams = EventTeamManipulator.createOrUpdate([ EventTeam(id=event_key + "_" + team.key.id(), event=event.key, team=team.key, year=event.year) for team in teams ]) template_values = { 'awards': new_awards, } path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html') self.response.out.write(template.render(path, template_values))
def get(self, event_key): datafeed = DatafeedFMSAPI('v2.0') event = Event.get_by_id(event_key) new_awards = AwardManipulator.createOrUpdate(datafeed.getAwards(event)) if new_awards is None: new_awards = [] elif type(new_awards) != list: new_awards = [new_awards] # create EventTeams team_ids = set() for award in new_awards: for team in award.team_list: team_ids.add(team.id()) teams = TeamManipulator.createOrUpdate([Team( id=team_id, team_number=int(team_id[3:])) for team_id in team_ids]) if teams: if type(teams) is not list: teams = [teams] event_teams = EventTeamManipulator.createOrUpdate([EventTeam( id=event_key + "_" + team.key.id(), event=event.key, team=team.key, year=event.year) for team in teams]) template_values = { 'awards': new_awards, } path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html') self.response.out.write(template.render(path, template_values))