def get_all_sports_teams(exclude=set()): other_teams = Team.select().where(~(Team.id << exclude)) team_data = {} for sport_type in Sport.SportType: team_data[sport_type.value] = [] for team in other_teams: team_data[team.sport_type.value].append(team) return team_data
def get_favorites(self): """ Get favorites for a user item. :return: list of favorite Team objects for the User. """ from app.models.favorite import Favorite join_predicate = ((Team.espn_id == Favorite.team) & (Team.sport_type == Favorite.sport_type)) favorites = Team.select().join( Favorite, on=join_predicate).where(Favorite.user_id == self.id) return favorites