def test_admin_team_standings(): app = create_ctfd(user_mode="teams") with app.app_context(): setup_app(app) team_standings = get_team_standings(admin=True) first_team = Teams.query.filter_by(id=team_standings[0].team_id).first_or_404() assert first_team.name == "team1" assert first_team.score == 100
def get_place(self, admin=False, numeric=False): """ This method is generally a clone of CTFd.scoreboard.get_standings. The point being that models.py must be self-reliant and have little to no imports within the CTFd application as importing from the application itself will result in a circular import. """ from CTFd.utils.scores import get_team_standings standings = get_team_standings(admin=admin) try: n = standings.index((self.id,)) + 1 if numeric: return n return ordinalize(n) except ValueError: return None
def get_place(self, admin=False): """ This method is generally a clone of CTFd.scoreboard.get_standings. The point being that models.py must be self-reliant and have little to no imports within the CTFd application as importing from the application itself will result in a circular import. """ from CTFd.utils.scores import get_team_standings standings = get_team_standings(admin=admin) # http://codegolf.stackexchange.com/a/4712 try: i = standings.index((self.id, )) + 1 k = i % 10 return "%d%s" % (i, "tsnrhtdd"[(i / 10 % 10 != 1) * (k < 4) * k::4]) except ValueError: return 0
def get_place(self, admin=False, numeric=False): """ This method is generally a clone of CTFd.scoreboard.get_standings. The point being that models.py must be self-reliant and have little to no imports within the CTFd application as importing from the application itself will result in a circular import. """ from CTFd.utils.scores import get_team_standings standings = get_team_standings(admin=admin) for i, team in enumerate(standings): if team.team_id == self.id: n = i + 1 if numeric: return n return ordinalize(n) else: return None