Example #1
0
    def get(self, attribute, value):
        medal_schema = SportCountryMedalsSchema(many=True)

        if attribute == 'country':
            medals = SportCountryMedals.query.filter_by(
                country_id=value).order_by(
                    SportCountryMedals.gold.desc()).all()
            return schema_to_json(medal_schema, medals)

        elif attribute == 'sport':
            medals = SportCountryMedals.query.filter_by(
                sport_id=value).order_by(SportCountryMedals.gold.desc()).all()
            return schema_to_json(medal_schema, medals)
Example #2
0
    def get(self, attribute, value):
        athlete_schema = AthleteSchema(many=True)

        if attribute == 'country':
            athletes = Athlete.query.filter_by(country_id=value).all()
            return schema_to_json(athlete_schema, athletes)

        elif attribute == 'sport':
            sport_record = Sport.query.filter_by(_id=value).first()
            return schema_to_json(athlete_schema, sport_record.athletes.all())

        elif attribute == 'weight':
            athletes = Athlete.query.filter_by(weight=value).all()
            return schema_to_json(athlete_schema, athletes)

        elif attribute == 'height':
            athletes = Athlete.query.filter_by(height=value).all()
            return schema_to_json(athlete_schema, athletes)

        elif attribute == 'age':
            athletes = Athlete.query.filter_by(age=value).all()
            return schema_to_json(athlete_schema, athletes)
Example #3
0
 def get(self):
     medal_schema = SportCountryMedalsSchema(many=True)
     medals = SportCountryMedals.query.order_by(
         SportCountryMedals.gold.desc()).all()
     return schema_to_json(medal_schema, medals)
Example #4
0
 def get(self, value):
     schedule_schema = ScheduleSchema(many=True)
     sport_record = Sport.query.filter_by(_id=value).first()
     return schema_to_json(schedule_schema, sport_record.schedules)
Example #5
0
 def get(self):
     schedule_schema = ScheduleSchema(many=True)
     schedules = Schedule.query.order_by(Schedule.daytime.desc()).all()
     return schema_to_json(schedule_schema, schedules)
Example #6
0
 def get(self):
     athlete_schema = AthleteSchema(many=True)
     athletes = Athlete.query.all()
     return schema_to_json(athlete_schema, athletes)
Example #7
0
 def get(self, id):
     athlete_schema = AthleteSchema()
     athlete = Athlete.query.filter_by(_id=id).first()
     return schema_to_json(athlete_schema, athlete)