Ejemplo n.º 1
0
def inactive_coach_cards(coach_id, **kwargs):
    """Activates coach"""
    coach = kwargs['coach']
    if coach is None:
        abort(404)
    result = cards_schema.dump(coach.inactive_cards())
    return jsonify(result.data)
Ejemplo n.º 2
0
 def cards(tourn):
     cards = []
     for ts in tourn.tournament_signups:
         for card in ts.deck.cards:
             if DeckService.is_enabled(ts.deck, card):
                 cards.append(card)
         for card in ts.deck.squad.cards:
             if DeckService.is_enabled(ts.deck, card):
                 cards.append(card)
     extra_cards = []
     for ts in tourn.tournament_signups:
         for c in ts.deck.extra_cards:
             c['coach_data'] = {
                 'id': ts.coach.id,
                 'name': ts.coach.short_name(),
                 'bb2_name': ts.coach.bb2_name
             }
             if DeckService.is_enabled(ts.deck, c):
                 extra_cards.append(c)
     result = cards_schema.dump(cards).data
     return result + extra_cards
Ejemplo n.º 3
0
def get_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)

    coach = Coach.query.options(raiseload(Coach.cards),raiseload(Coach.packs)).filter_by(disc_id=current_user()['id']).one_or_none()

    if not deck.commited and not (coach.id==deck.tournament_signup.coach.id or coach.short_name()=="TomasT"):
        raise InvalidUsage("Deck not commited, only owner can display it!", status_code=403)

    # is committed    
    if deck.tournament_signup.tournament.phase=="deck_building" and not (coach.id==deck.tournament_signup.coach.id or coach.short_name()==deck.tournament_signup.tournament.admin or coach.short_name()=="TomasT"):
        raise InvalidUsage("Only owner and admin can see display commited deck in the Deck Building phase!", status_code=403)    

    starter_cards = CoachService.get_starter_cards(deck.tournament_signup.coach)
    result = deck_schema.dump(deck)
    result2 = cards_schema.dump(starter_cards)
    return jsonify({'deck':result.data, 'starter_cards':result2.data})
Ejemplo n.º 4
0
def get_starter_cards():
    starter_cards = PackService.generate("starter").cards
    result = cards_schema.dump(starter_cards)
    return jsonify(result.data)