Esempio n. 1
0
File: views.py Progetto: Amoki/bois
def player(request):
    check_params(request, ('first_name', 'sex'))

    player = Player(
        first_name=request.data.get('first_name'),
        sex=request.data.get('sex'),
    )
    player.save()
    return Response(PlayerSerializer(player).data)
Esempio n. 2
0
File: views.py Progetto: Amoki/bois
def post_game(request):
    check_params(request, ['category', 'players'])

    players = Player.objects.filter(pk__in=request.data.get('players'))
    category = Category.objects.get(pk=request.data.get('category'))

    male = False
    female = False

    for player in players:
        if player.sex == Player.MALE:
            male = True
        else:
            female = True

    game = Game(category=category, mixte=(male and female))
    game.save()
    game.players.add(*players)

    request.session['game'] = game.pk

    return redirect('/game')
Esempio n. 3
0
File: views.py Progetto: Amoki/bois
def follow(request):
    check_params(request, ('game',))

    return render(request, 'follow.html', {game: request.data.get('game')})