Ejemplo n.º 1
0
def removecardextra_deck(deck_id):
    if not current_user():
        raise InvalidUsage('You are not authenticated', status_code=401)
    deck = Deck.query.get(deck_id)
    if deck is None:
        abort(404)
    if locked(deck):
            raise InvalidUsage("Deck is locked!", status_code=403)

    coach = Coach.query.options(raiseload(Coach.cards),raiseload(Coach.packs)).filter_by(disc_id=current_user()['id']).one_or_none()
    if deck.tournament_signup.coach!=coach:
        raise InvalidUsage("Unauthorized access!", status_code=403)

    card = request.get_json()
    try:
        deck = DeckService.removeextracard(deck,card)
    except (DeckError) as e:            
        raise InvalidUsage(str(e), status_code=403)

    result = deck_schema.dump(deck)
    return jsonify(result.data)
Ejemplo n.º 2
0
def removecardextra_deck(deck):
    """Removes extra card from deck"""
    return DeckService.removeextracard(deck, request.get_json())