From eb2e18c7400c03d47ddea88188c4c6f20c3a418c Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 24 Aug 2022 01:08:35 +0300 Subject: [PATCH] migrate --- .deploy/deploy-prod.yaml | 17 +++++++++++++++++ battleship/views.py | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/.deploy/deploy-prod.yaml b/.deploy/deploy-prod.yaml index 1f72e42..999cf93 100644 --- a/.deploy/deploy-prod.yaml +++ b/.deploy/deploy-prod.yaml @@ -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 diff --git a/battleship/views.py b/battleship/views.py index 4d671ea..896a4cb 100644 --- a/battleship/views.py +++ b/battleship/views.py @@ -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']) })