migrate
This commit is contained in:
@@ -9,6 +9,8 @@ from battleship.utils import check_field
|
||||
|
||||
@csrf_exempt
|
||||
def new_game(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
game = Game.objects.create()
|
||||
player1 = Player.objects.create(
|
||||
game=game,
|
||||
@@ -28,6 +30,8 @@ def new_game(request):
|
||||
|
||||
@csrf_exempt
|
||||
def attend_game(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
game_id = request.POST['game_id']
|
||||
attend_token = request.POST['attend_token']
|
||||
player = Player.objects.get(game_id=game_id, attend_token=attend_token)
|
||||
@@ -42,6 +46,8 @@ def attend_game(request):
|
||||
|
||||
@csrf_exempt
|
||||
def place_ships(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
game_id = request.POST['game_id']
|
||||
token = request.POST['token']
|
||||
player = Player.objects.get(game_id=game_id, token=token)
|
||||
@@ -57,6 +63,8 @@ def place_ships(request):
|
||||
|
||||
@csrf_exempt
|
||||
def check_opponent(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
game_id = request.POST['game_id']
|
||||
token = request.POST['token']
|
||||
player = Player.objects.get(game_id=game_id, token=token)
|
||||
@@ -68,6 +76,8 @@ def check_opponent(request):
|
||||
|
||||
@csrf_exempt
|
||||
def shoot(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
game_id = request.POST['game_id']
|
||||
token = request.POST['token']
|
||||
player = Player.objects.get(game_id=game_id, token=token)
|
||||
@@ -105,6 +115,8 @@ def shoot(request):
|
||||
|
||||
@csrf_exempt
|
||||
def check_status(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
game_id = request.POST['game_id']
|
||||
token = request.POST['token']
|
||||
player = Player.objects.get(game_id=game_id, token=token)
|
||||
@@ -117,6 +129,8 @@ def check_status(request):
|
||||
|
||||
@csrf_exempt
|
||||
def check_field_correct(request):
|
||||
if request.method == 'OPTIONS':
|
||||
return JsonResponse({})
|
||||
return JsonResponse({
|
||||
'correct': check_field(request.POST['field'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user