Exemplo n.º 1
0
def tournament_sign(tournament_id, **kwargs):
    """Sign coach into tournament"""
    try:
        coach = kwargs['coach']

        tourn = Tournament.query.get(tournament_id)
        TournamentService.register(tourn, coach)
        result = tournament_schema.dump(tourn)
        return jsonify(result.data)
    except RegistrationError as exc:
        raise InvalidUsage(str(exc), status_code=403)
Exemplo n.º 2
0
def tournament_sign(tournament_id):
    if current_user():
        try:
            tourn = Tournament.query.get(tournament_id)
            coach = Coach.query.filter_by(disc_id=current_user()['id']).one_or_none()
            if not coach:
                raise InvalidUsage("Coach not found", status_code=403)    
            TournamentService.register(tourn,coach)
            result = tournament_schema.dump(tourn)
            return jsonify(result.data)
        except RegistrationError as e:
            raise InvalidUsage(str(e), status_code=403)
    else:
        raise InvalidUsage('You are not authenticated', status_code=401)
Exemplo n.º 3
0
async def sign(tournament_id, coach, ctx, admin=False):
    """routine to sign a coach to tournament"""
    if admin:
        tourn = Tournament.query.filter_by(
            tournament_id=tournament_id).one_or_none()
    else:
        tourn = Tournament.query.filter_by(
            status="OPEN", tournament_id=tournament_id).one_or_none()
    if not tourn:
        raise ValueError("Incorrect **tournament_id** specified")

    signup = TournamentService.register(tourn, coach, admin)
    add_msg = "" if signup.mode == "active" else " as RESERVE"
    await ctx.send(f"Signup succeeded{add_msg}!!!")
    return True