def person_api(person): try: p = ps.load_person(person) p.decks_url = url_for('person_decks_api', person=person) p.head_to_head = url_for('person_h2h_api', person=person) return return_json(p) except DoesNotExistException: return return_json(generate_error('NOTFOUND', 'Person does not exist'))
def person_api(person: str, season_id: int = -1) -> Response: if season_id == -1: season_id = rotation.current_season_num() try: p = ps.load_person_by_discord_id_or_username(person, season_id) p.decks_url = url_for('person_decks_api', person=person, season_id=season_id) p.head_to_head = url_for('person_h2h_api', person=person, season_id=season_id) return return_json(p) except DoesNotExistException: return return_json(generate_error('NOTFOUND', 'Person does not exist'))
def drop(person): error = validate_api_key() if error: return error decks = league.active_decks_by(person) if len(decks) == 0: return return_json(generate_error('NO_ACTIVE_RUN', 'That person does not have an active run')) run = guarantee.exactly_one(decks) league.retire_deck(run) result = {'success':True} return return_json(result)
def test_500() -> Response: if configuration.get_bool('production'): return return_json(generate_error( 'ON_PROD', 'This only works on test environments'), status=404) raise TooManyItemsException()