def update_deck(deck_id): if current_user(): 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) received_deck = request.get_json()['deck'] deck = DeckService.update(deck,received_deck) result = deck_schema.dump(deck) return jsonify(result.data) else: raise InvalidUsage('You are not authenticated!', status_code=401)
def update_deck(deck): """Updates base deck info not cards""" return DeckService.update(deck, request.get_json()['deck'])