-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from hackathone-prosept-team2/develop
Develop
- Loading branch information
Showing
38 changed files
with
1,388 additions
and
23,868 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,9 @@ POSTGRES_USER=postgres | |
POSTGRES_PASSWORD=postgres | ||
POSTGRES_HOST=db | ||
POSTGRES_PORT=5432 | ||
|
||
ADMIN_EMAIL=[email protected] | ||
ADMIN_PASSWORD=Password-123 | ||
|
||
# Domain for frontend docker container | ||
DOMAIN_URL=http://127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: mafia-app workflow | ||
|
||
on: | ||
push: | ||
branches: [develop] | ||
|
||
jobs: | ||
build_and_push_to_docker_hub: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Docker | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Push to Docker Hub | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
context: ./ | ||
tags: ${{ secrets.DOCKER_USERNAME }}/prosept_back:latest | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build_and_push_to_docker_hub | ||
steps: | ||
- name: executing remote ssh commands to deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USER }} | ||
key: ${{ secrets.SSH_KEY }} | ||
passphrase: ${{ secrets.PASSPHRASE }} | ||
password: ${{ secrets.PASSPHRASE }} | ||
script: | | ||
cd prosept_app/deploy/ | ||
sudo docker-compose down | ||
sudo docker rm prosept_back | ||
sudo docker rm prosept_nginx | ||
sudo docker rmi ${{ secrets.DOCKER_USERNAME }}/prosept_back | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/prosept_back:latest | ||
sudo docker-compose up -d --build | ||
sudo docker exec -i prosept_back python manage.py migrate | ||
sudo docker exec -i prosept_back python manage.py collectstatic --noinput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
from django.shortcuts import get_object_or_404 | ||
from rest_framework.generics import ListAPIView | ||
from rest_framework import views, status | ||
from rest_framework.response import Response | ||
|
||
from apps.dealers.models import DealerKey | ||
from apps.prices.crud import list_key_prices | ||
from apps.prices.services import delete_prices_and_relations, create_prices | ||
|
||
from ..pagination import NestedPagePagination | ||
from . import serializer as ser | ||
|
||
|
||
class KeyPriceViewset(ListAPIView): | ||
class KeyPriceView(ListAPIView): | ||
"""Цены дилеров компании Просепт по 1 ключу.""" | ||
|
||
pagination_class = NestedPagePagination | ||
serializer_class = ser.KeyPriceSerializer | ||
|
||
def get_queryset(self): | ||
key_pk = self.kwargs.get("pk") | ||
dealer_key = get_object_or_404(DealerKey, pk=key_pk) | ||
return list_key_prices(dealer_key=dealer_key) | ||
return list_key_prices(key_pk=key_pk) | ||
|
||
|
||
class PricesView(views.APIView): | ||
"""Загрузка и удаление цен дилеров и связанных ключей дилеров.""" | ||
|
||
def post(self, request): | ||
create_prices() | ||
return Response(status=status.HTTP_201_CREATED) | ||
|
||
def delete(self, request): | ||
delete_prices_and_relations() | ||
return Response(status=status.HTTP_204_NO_CONTENT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
from django.urls import include, path | ||
from rest_framework import routers | ||
|
||
from .dealers.views import DealerViewset, DealerKeyViewset | ||
from .prices.views import KeyPriceViewset | ||
from .dealers.views import ( | ||
ChooseMatchView, | ||
DealerViewset, | ||
DealerKeyViewset, | ||
MatchView, | ||
DeclineMatchesView, | ||
DealersReport, | ||
) | ||
from .prices.views import PricesView, KeyPriceView | ||
from .products.views import ProductViewset | ||
from .users.views import UserViewset | ||
|
||
app_name = "api" | ||
|
||
router = routers.DefaultRouter() | ||
router.register("products", ProductViewset, "products") | ||
router.register("dealers", DealerViewset, "dealers") | ||
router.register("keys", DealerKeyViewset, "keys") | ||
# router.register("keys/<int:pk>/prices", KeyPriceViewset, "prices") | ||
router.register("auth/users", UserViewset, "users") | ||
|
||
urlpatterns = [ | ||
path("keys/<int:pk>/prices", KeyPriceViewset.as_view(), name="key_prices"), | ||
path("dealers/report/", DealersReport.as_view(), name="dealers_report"), | ||
path("keys/<int:pk>/prices/", KeyPriceView.as_view(), name="key_prices"), | ||
path("keys/<int:pk>/matches/", MatchView.as_view(), name="get_matches"), | ||
path( | ||
"keys/<int:pk>/choose_match/", | ||
ChooseMatchView.as_view(), | ||
name="choose_match", | ||
), | ||
path( | ||
"keys/<int:pk>/decline_matches/", | ||
DeclineMatchesView.as_view(), | ||
name="decline_all_matches", | ||
), | ||
path("prices/", PricesView.as_view(), name="add_and_delete_prices"), | ||
path("", include(router.urls)), | ||
path('auth/', include('djoser.urls')), | ||
path('auth/', include('djoser.urls.authtoken')), | ||
path("auth/", include("djoser.urls.authtoken")), | ||
] |
Oops, something went wrong.