Пример #1
0
def index():
    """the main screen for the game"""
    ranked_teams = sorted(app.league.teams, key=lambda x: x.current_season_stats().wins * 2 + x.current_season_stats().ties, reverse=True)
    top_scorers = list(PlayerStats.select().join(Season).where(Season.is_current == True, Season.league == app.league))
    top_scorers = sorted(top_scorers, key=lambda x: x.goals + x.assists, reverse=True)[:10]
    goalies = Player.select().where(Player.position == 'G')
    goalie_stats = list(PlayerStats.select().join(Season).where(Season.is_current == True,
        Season.league == app.league, PlayerStats.player << goalies))
    return render_template("index.html", teams=ranked_teams, top_scorers=top_scorers, top_goalies=goalie_stats)
Пример #2
0
    def setUp(self):
        db.init(':memory:')
        classes = [Team, League, Season, Person, Player, PlayerStats]
        db.create_tables(classes)
        for class_ in classes:
            if class_.__name__ not in PMDataObject.deferred_relations:
                PMDataObject.deferred_relations[class_.__name__] = class_
        
        self.league = League.create(name="Band Battle")
        self.season = Season.create(league=self.league,
                start_year=2016,
                end_year=2017,
                is_current=True)

        self.team = Team.create(name="Sex Bob-omb", 
                city="Toronto", 
                skill=90,
                abbreviation="TOR", 
                league=self.league)
        self.person = Person.create(forename="Scott", surname="Pilgrim")
        self.player = Player.create(person=self.person,
                team=self.team,
                position="F",
                scoring_rate=12.0,
                shot_rate=12.0,
                )
        self.stats = PlayerStats.create(player=self.player,
                season=self.season,
                team=self.team)