From 698aafee5afbbf62745e6a3494596d6eb292b5e7 Mon Sep 17 00:00:00 2001 From: Marat Date: Thu, 3 May 2018 19:39:46 +0000 Subject: [PATCH 1/3] Update Envoy.blade.php --- Envoy.blade.php | 105 ++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 47 deletions(-) diff --git a/Envoy.blade.php b/Envoy.blade.php index 3e4599d..263f507 100644 --- a/Envoy.blade.php +++ b/Envoy.blade.php @@ -1,4 +1,5 @@ @servers(['localhost' => 'deployer@192.168.0.13']) +@servers(['dev' => 'deployer@192.168.0.5']) @setup $repository = 'ssh://git@g.skillbox.ru:22004/kor_a_m/skill-back.git'; @@ -18,68 +19,78 @@ deployment_option_cleanup @endstory -@task('clone_repository', ['on' => 'localhost']) -echo '>> Клонируем репозиторий' +@story('deploydev', ['on' => 'dev']) + clone_repository + create_symlinks + install_req + run_tests + run_migrate + update_symlinks + deployment_option_cleanup +@endstory -echo '{{ $new_release_dir }}' -[ -d {{ $releases_dir }} ] || mkdir {{ $releases_dir }} -@if ($branch) - git clone -b {{ $branch }} {{ $repository }} {{ $new_release_dir }} -@endif +@task('clone_repository') + echo '>> Клонируем репозиторий' + + echo '{{ $new_release_dir }}' + [ -d {{ $releases_dir }} ] || mkdir {{ $releases_dir }} + @if ($branch) + git clone -b {{ $branch }} {{ $repository }} {{ $new_release_dir }} + @endif @endtask -@task('create_symlinks', ['on' => 'localhost']) -echo '>> Создание симлинков' -ln -s {{ $app_dir }}/configs/master/ssl {{ $new_release_dir }}/ssl -@if ($branch == 'master') - ln -nfs {{ $app_dir }}/configs/master/prod.env {{ $new_release_dir }}/config_app/settings/local.env - ln -nfs {{ $app_dir }}/media/master {{ $new_release_dir }}/media -@endif -@if ($branch == 'dev') - ln -nfs {{ $app_dir }}/configs/dev/dev.env {{ $new_release_dir }}/config_app/settings/local.env - ln -nfs {{ $app_dir }}/media/master {{ $new_release_dir }}/media -@endif -ln -nfs {{ $app_dir }}/logs/{{ $branch }} {{ $new_release_dir }}/logs +@task('create_symlinks') + echo '>> Создание симлинков' + ln -s {{ $app_dir }}/configs/master/ssl {{ $new_release_dir }}/ssl + @if ($branch == 'master') + ln -nfs {{ $app_dir }}/configs/master/prod.env {{ $new_release_dir }}/config_app/settings/local.env + ln -nfs {{ $app_dir }}/media/master {{ $new_release_dir }}/media + @endif + @if ($branch == 'dev') + ln -nfs {{ $app_dir }}/configs/dev/dev.env {{ $new_release_dir }}/config_app/settings/local.env + ln -nfs {{ $app_dir }}/media/master {{ $new_release_dir }}/media + @endif + ln -nfs {{ $app_dir }}/logs/{{ $branch }} {{ $new_release_dir }}/logs @endtask -@task('install_req', ['on' => 'localhost']) -echo '>> Подтягиваем зависимости' -@if ($branch) - cd {{ $new_release_dir }} - source /env/bin/activate && pip install -r requirements.txt -@endif +@task('install_req') + echo '>> Подтягиваем зависимости' + @if ($branch) + cd {{ $new_release_dir }} + source /env/bin/activate && pip install -r requirements.txt + @endif @endtask -@task('run_tests', ['on' => 'localhost']) -echo '>> Запускаем тесты' -@if ($branch) - cd {{ $new_release_dir }} - source /env/bin/activate && python manage.py test -@endif +@task('run_tests') + echo '>> Запускаем тесты' + @if ($branch) + cd {{ $new_release_dir }} + source /env/bin/activate && python manage.py test + @endif @endtask -@task('run_migrate', ['on' => 'localhost']) -echo '>> Запускаем миграции' -@if ($branch) - cd {{ $new_release_dir }} - source /env/bin/activate && python manage.py migrate -@endif +@task('run_migrate') + echo '>> Запускаем миграции' + @if ($branch) + cd {{ $new_release_dir }} + source /env/bin/activate && python manage.py migrate + @endif @endtask -@task('update_symlinks', ['on' => 'localhost']) -@if ($branch) - ln -nfs {{ $app_dir }}/configs/{{ $branch }}/wsgi.py {{ $new_release_dir }}/lms/wsgi.py - echo '>> Создаем симлинк на папку текущего релиза' - ln -nfs {{ $new_release_dir }} {{ $app_dir }}/current_{{ $branch }} - echo '>> restart Supervisor' - supervisorctl restart {{ $branch }}: -@endif +@task('update_symlinks') + @if ($branch) + ln -nfs {{ $app_dir }}/configs/{{ $branch }}/wsgi.py {{ $new_release_dir }}/lms/wsgi.py + echo '>> Создаем симлинк на папку текущего релиза' + ln -nfs {{ $new_release_dir }} {{ $app_dir }}/current_{{ $branch }} + echo '>> restart Supervisor' + supervisorctl restart {{ $branch }}: + @endif @endtask @task('deployment_option_cleanup') cd {{ $releases_dir }} @if ( isset($cleanup) && $cleanup ) - find . -maxdepth 1 -name "20*{{ $branch }}" -mmin +30 | head -n 3 | xargs rm -Rf - echo "Cleaned up old deployments" + find . -maxdepth 1 -name "20*{{ $branch }}" -mmin +30 | head -n 3 | xargs rm -Rf + echo "Cleaned up old deployments" @endif @endtask From dc919e555e5ec40a2d72ee1eb901b2505a23d742 Mon Sep 17 00:00:00 2001 From: Marat Date: Thu, 3 May 2018 19:40:04 +0000 Subject: [PATCH 2/3] Update .gitlab-ci.yml --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 216d6d4..7835e76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,7 @@ deploy_branch: - ssh-add <(echo "$SSH_PRIVATE_KEY") - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - - ~/.composer/vendor/bin/envoy run deploy --cleanup --branch="$CI_BUILD_REF_SLUG" + - ~/.composer/vendor/bin/envoy run deploydev --cleanup --branch="$CI_BUILD_REF_SLUG" environment: name: production url: https://go.skillbox.ru From 6d943fc50e2f137f46d1b0a0c2a32c6e57b87db8 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 4 May 2018 12:35:31 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D0=B8=D1=81=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D1=87=D0=B8=D0=BD=D0=B3=D0=B0=20=D0=BA=20=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=B6=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- finance/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/finance/views.py b/finance/views.py index bfb195b..31aeff0 100644 --- a/finance/views.py +++ b/finance/views.py @@ -140,8 +140,11 @@ class InvoiceDetailView(APIView): price = request.JSON.get('price', None) comment = request.JSON.get('comment', None) real_price = request.JSON.get('real_price', None) + key = request.JSON.get('key', None) pay_count = int(request.JSON.get('pay_count', '1')) + print(key) + if bill_id is None: return Response("Не передан id счёта", status=400) @@ -188,13 +191,10 @@ class InvoiceDetailView(APIView): if invoice.status == "F": return Response(InvoiceSerializer(invoice).data, status=200) - invoice.real_price = None + invoice.real_price = real_price invoice.method = method invoice.status = status - - if invoice.status == "F": - # TODO это никогда не выполнится - invoice.real_price = invoice.real_price if real_price is None else real_price + invoice.key = key if bill.check_pay() and (invoice.price < price): return Response("""Нельзя менять стоимость по счёту в большую сторону,