This commit is contained in:
Administrator 2022-08-24 01:08:35 +03:00
parent bb8ac8edbc
commit eb2e18c740
2 changed files with 31 additions and 0 deletions

View File

@ -36,6 +36,23 @@ services:
parallelism: 1
order: start-first
remove:
image: mathwave/sprint-repo:battleship-back
networks:
- battleship-net
environment:
DB_HOST: "pg.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_DEV
DEBUG: "false"
command: ./manage.py remove
deploy:
mode: replicated
restart_policy:
condition: any
update_config:
parallelism: 1
order: start-first
networks:
battleship-net:
driver: overlay

View File

@ -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'])
})