From 642b8ca73d8f3be1f908be309f6c18f1715fcd24 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 31 May 2024 09:05:23 +0300 Subject: [PATCH 01/13] external el --- front/components/element.vue | 34 +++++++++++++++++++ .../p_[org_id]/i_[inv_id]/index.vue | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 front/components/element.vue diff --git a/front/components/element.vue b/front/components/element.vue new file mode 100644 index 0000000..da4f90e --- /dev/null +++ b/front/components/element.vue @@ -0,0 +1,34 @@ + + \ No newline at end of file diff --git a/front/pages/organization/p_[org_id]/i_[inv_id]/index.vue b/front/pages/organization/p_[org_id]/i_[inv_id]/index.vue index cece1c6..c26496b 100644 --- a/front/pages/organization/p_[org_id]/i_[inv_id]/index.vue +++ b/front/pages/organization/p_[org_id]/i_[inv_id]/index.vue @@ -33,6 +33,10 @@ onMounted(async () => {
+ :columns="makeColumns(['id', 'external_id', 'element_id', 'photo', 'additional_text'])"> + +
\ No newline at end of file From 2e361ff919cb6225587b98a1020f0a0b8eeefbd7 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 31 May 2024 09:05:28 +0300 Subject: [PATCH 02/13] external el in edit --- front/assets/main.scss | 6 +++--- front/components/edit.vue | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/front/assets/main.scss b/front/assets/main.scss index 324d6e7..12b0456 100644 --- a/front/assets/main.scss +++ b/front/assets/main.scss @@ -40,12 +40,12 @@ } dl { - // @apply grid grid-cols-4; + @apply grid grid-cols-12; dt { - // @apply col-span-1 + @apply col-span-full } dd { - @apply mb-2 + @apply mb-2 col-span-full col-start-2 } diff --git a/front/components/edit.vue b/front/components/edit.vue index 329a826..13da419 100644 --- a/front/components/edit.vue +++ b/front/components/edit.vue @@ -183,11 +183,8 @@ onMounted(async () => {

{{ external_data.partner?.find(el => el["Ref_Key"] == state.partner)?.Description }}

From 877f99f466ee5d185f8b37a3a95d4cf113b9627d Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 31 May 2024 09:48:48 +0300 Subject: [PATCH 03/13] uniq --- back/api/settings.py | 1 + back/inventory/models.py | 4 ++-- back/inventory/serializers.py | 7 +++++- back/inventory/views.py | 37 ++++++++++++++++++------------- dev.sh | 2 +- front/components/edit.vue | 41 +++++++++++++++++++---------------- front/components/element.vue | 4 +--- 7 files changed, 55 insertions(+), 41 deletions(-) diff --git a/back/api/settings.py b/back/api/settings.py index e1d980d..e25af13 100644 --- a/back/api/settings.py +++ b/back/api/settings.py @@ -31,6 +31,7 @@ DEBUG = True ALLOWED_HOSTS = [] CORS_ALLOWED_ORIGINS = [ 'http://localhost:3000', + 'http://192.168.103.159:3000' ] # Application definition diff --git a/back/inventory/models.py b/back/inventory/models.py index ac18d18..683a8c1 100644 --- a/back/inventory/models.py +++ b/back/inventory/models.py @@ -34,8 +34,8 @@ class Element(models.Model): id = models.AutoField(primary_key=True) external_id = models.CharField() element_id = models.CharField(max_length=100) - photo = models.ImageField(upload_to=".") - additional_text = models.TextField() + photo = models.ImageField(upload_to=".", null=True) + additional_text = models.TextField(null=True, blank=True, default="") created_at = models.DateTimeField(auto_now_add=True) inventory = models.ForeignKey( diff --git a/back/inventory/serializers.py b/back/inventory/serializers.py index e1aecff..87c7160 100644 --- a/back/inventory/serializers.py +++ b/back/inventory/serializers.py @@ -1,4 +1,6 @@ from rest_framework import serializers +from rest_framework.validators import UniqueValidator + from .models import Element, InventoryItem, Partner import logging @@ -37,7 +39,10 @@ class InventorySerializer(serializers.ModelSerializer): class ElementSerializer(serializers.ModelSerializer): inventory_name = serializers.CharField(source="inventory.name", read_only=True) - + element_id = serializers.CharField( + max_length=100, + validators=[UniqueValidator(queryset=Element.objects.all())] + ) class Meta: model = Element fields = [ diff --git a/back/inventory/views.py b/back/inventory/views.py index 7ff0a92..75d7424 100644 --- a/back/inventory/views.py +++ b/back/inventory/views.py @@ -158,21 +158,28 @@ class ElementViewSet(viewsets.ModelViewSet): ) inventory_serializer = InventorySerializer(inventory_object, many=False) - element_item = Element.objects.create( - inventory=inventory_object, - external_id=data["element"], - element_id=data["element_id"], - additional_text=data["element_additional_data"], - ) - element_serializer = ElementSerializer(element_item, many=False) - - return Response( - { - "partner": partner_serializer.data, - "inventory": inventory_serializer.data, - "element": element_serializer.data, - } - ) + element_data = { + "inventory": inventory_object.id, + "external_id": data["element"], + "element_id": data["element_id"], + } + if "element_additional_data" in data: + element_data["additional_text"] = data["element_additional_data"] + element_serializer = ElementSerializer(data=element_data, many=False) + if element_serializer.is_valid(): + element_data["inventory"] = inventory_object + Element.objects.create(**element_data) + return Response( + { + "partner": partner_serializer.data, + "inventory": inventory_serializer.data, + "element": element_serializer.data, + } + ) + else: + return Response( + element_serializer.errors, status=status.HTTP_500_INTERNAL_SERVER_ERROR + ) @action( detail=False, diff --git a/dev.sh b/dev.sh index 15d80e0..53b3d51 100755 --- a/dev.sh +++ b/dev.sh @@ -1,3 +1,3 @@ #!/bin/bash -x-terminal-emulator -title "To Invetory FRONT" -e "cd front && npm run dev"& +x-terminal-emulator -title "To Invetory FRONT" -e "cd front && npm run dev -- --host"& x-terminal-emulator -title "To Invetory BACK" -e "poetry run task server" \ No newline at end of file diff --git a/front/components/edit.vue b/front/components/edit.vue index 13da419..700d218 100644 --- a/front/components/edit.vue +++ b/front/components/edit.vue @@ -36,20 +36,7 @@ const external_data = reactive({ categories: [], element: [], }) - -const external_elements = reactive({}) -const loadOneElement = async (id: string) => { - const data = await $fetch(`${apiBase}/element/external/id/${id}`) - external_elements[id] = data.Description - -} -const getExternalElementName = (id: string) => { - if (!external_elements[id]) { - loadOneElement(id) - return id - } - return external_elements[id] -} +const show_error = ref() const elements = ref(props.elements) const validate = (state: any): FormError[] => { @@ -60,24 +47,37 @@ const validate = (state: any): FormError[] => { errors.push({ path: 'partner', message: txt }) } if (!state.element_id) errors.push({ path: 'element_id', message: txt }) - if (!state.element_additional_data) errors.push({ path: 'element_additional_data', message: txt }) + // if (!state.element_additional_data) errors.push({ path: 'element_additional_data', message: txt }) return errors } async function onSubmit(event: FormSubmitEvent) { + show_error.value = undefined const prepader_data = event.data if (!external_data || !external_data.partner) { return false } prepader_data.partner_name = external_data.partner.find(el => el.Ref_Key == state.partner)?.Description - const data = await $fetch(`${apiBase}/element/`, { method: 'POST', body: JSON.stringify(prepader_data) }) + const data = await $fetch(`${apiBase}/element/`, { + method: 'POST', body: JSON.stringify(prepader_data), onResponseError: (error) => { + if (error.response.status == 500) { + show_error.value = Object.entries(error.response._data).map(el => `${el[0]}: ${el[1]}`).join('\n') + } + } + }) const inv_id = route.params.inv_id || data.inventory?.id if (!route.params.inv_id) { navigateTo(`/organization/p_${data.partner.id}/i_${data.inventory.id}`) } else { const newElements = await $fetch(`${apiBase}/element?inventory_id=${inv_id}`, { headers }) elements.value = newElements.results + external_data.element = [] + external_data.categories = [] + state.categories = [] + state.element = undefined + state.element_id = undefined + state.element_additional_data = undefined } } @@ -170,7 +170,7 @@ onMounted(async () => { - + @@ -179,11 +179,14 @@ onMounted(async () => { -
+

{{ external_data.partner?.find(el => el["Ref_Key"] == state.partner)?.Description }}

+
diff --git a/front/components/element.vue b/front/components/element.vue index da4f90e..60c540f 100644 --- a/front/components/element.vue +++ b/front/components/element.vue @@ -28,7 +28,5 @@ watch(external_elements, () => { }, { deep: true }) \ No newline at end of file From a56dcbd4d2c9ef8af00dbe118d4657070efb49fa Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 31 May 2024 10:08:01 +0300 Subject: [PATCH 04/13] local dev --- back/api/settings.py | 4 +++- front/assets/main.scss | 6 ++++-- front/components/edit.vue | 2 +- front/pages/organization/index.vue | 2 +- front/pages/organization/p_[org_id]/index.vue | 2 +- pyproject.toml | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/back/api/settings.py b/back/api/settings.py index e25af13..0c43fc7 100644 --- a/back/api/settings.py +++ b/back/api/settings.py @@ -28,7 +28,9 @@ SECRET_KEY = "django-insecure-ruo!wst&sb8(f9)j5u4rda-w!673lj_-c0a%gx_t@)ff*q*2ze # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = [ + '192.168.103.159' +] CORS_ALLOWED_ORIGINS = [ 'http://localhost:3000', 'http://192.168.103.159:3000' diff --git a/front/assets/main.scss b/front/assets/main.scss index 12b0456..d052622 100644 --- a/front/assets/main.scss +++ b/front/assets/main.scss @@ -45,8 +45,10 @@ @apply col-span-full } dd { - @apply mb-2 col-span-full col-start-2 - + @apply col-span-full col-start-2; + &:last-of-type { + @apply mb-2 + } } } diff --git a/front/components/edit.vue b/front/components/edit.vue index 700d218..853a292 100644 --- a/front/components/edit.vue +++ b/front/components/edit.vue @@ -188,7 +188,7 @@ onMounted(async () => {
{{ item.element_id }}
-
{{ item.additional_data }}
+
{{ item.additional_text }}
diff --git a/front/pages/organization/index.vue b/front/pages/organization/index.vue index 7653ec5..0159f85 100644 --- a/front/pages/organization/index.vue +++ b/front/pages/organization/index.vue @@ -12,7 +12,7 @@ const { data } = await useFetch(`${apiBase}/partner/`, { headers }) Новая инвентаризация
- + diff --git a/front/pages/organization/p_[org_id]/index.vue b/front/pages/organization/p_[org_id]/index.vue index 127777f..fde30ae 100644 --- a/front/pages/organization/p_[org_id]/index.vue +++ b/front/pages/organization/p_[org_id]/index.vue @@ -50,7 +50,7 @@ onMounted(async () => {
diff --git a/pyproject.toml b/pyproject.toml index d0c6514..76cf2c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,4 +27,4 @@ build-backend = "poetry.core.masonry.api" [tool.taskipy.tasks] migrate = "cd back && python manage.py makemigrations && python manage.py migrate" -server = "cd back && python manage.py runserver" \ No newline at end of file +server = "cd back && python manage.py runserver 0.0.0.0:8000" \ No newline at end of file From 153b7f601e41f8b8a67247e1298d964b60a1d329 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 31 May 2024 17:02:56 +0300 Subject: [PATCH 05/13] docker --- back/.env.example => .env.example | 3 +- .gitignore | 3 +- back/Dockerfile | 17 +++++ poetry.lock => back/poetry.lock | 95 ++++++++++++++++++++++----- pyproject.toml => back/pyproject.toml | 9 ++- compose-dev.yaml | 12 ++++ docker-compose.yml | 55 ++++++++++++++++ front/Dockerfile | 12 ++++ nginx/nginx.conf | 90 +++++++++++++++++++++++++ 9 files changed, 271 insertions(+), 25 deletions(-) rename back/.env.example => .env.example (66%) create mode 100644 back/Dockerfile rename poetry.lock => back/poetry.lock (76%) rename pyproject.toml => back/pyproject.toml (68%) create mode 100644 compose-dev.yaml create mode 100644 docker-compose.yml create mode 100644 front/Dockerfile create mode 100644 nginx/nginx.conf diff --git a/back/.env.example b/.env.example similarity index 66% rename from back/.env.example rename to .env.example index f8f7abc..625952c 100644 --- a/back/.env.example +++ b/.env.example @@ -2,4 +2,5 @@ DB_NAME= DB_USER= DB_PASSWORD= DB_HOST= -DB_PORT= \ No newline at end of file +DB_PORT= +ODATA_AUTH= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9db7fba..9bf75e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ .vscode/ -.venv/ \ No newline at end of file +.venv/ +.env \ No newline at end of file diff --git a/back/Dockerfile b/back/Dockerfile new file mode 100644 index 0000000..86dd8b8 --- /dev/null +++ b/back/Dockerfile @@ -0,0 +1,17 @@ +FROM ci.svs-tech.pro/library/node:22-bookworm-slim + +ENV WORKING_DIR=/app +WORKDIR ${WORKING_DIR} + +RUN apt-get update +RUN apt-get install python3-pip -y +RUN apt-get install python3-poetry -y + +RUN poetry -vvv --version + +COPY pyproject.toml poetry.lock ./ +RUN poetry install + +COPY . ${WORKING_DIR} + +CMD ["poetry", "run", "python", "manage.py", "runserver"] diff --git a/poetry.lock b/back/poetry.lock similarity index 76% rename from poetry.lock rename to back/poetry.lock index df6d55b..7ab348e 100644 --- a/poetry.lock +++ b/back/poetry.lock @@ -353,25 +353,84 @@ files = [ test = ["enum34", "ipaddress", "mock", "pywin32", "wmi"] [[package]] -name = "psycopg2" +name = "psycopg2-binary" version = "2.9.9" description = "psycopg2 - Python-PostgreSQL Database Adapter" optional = false python-versions = ">=3.7" files = [ - {file = "psycopg2-2.9.9-cp310-cp310-win32.whl", hash = "sha256:38a8dcc6856f569068b47de286b472b7c473ac7977243593a288ebce0dc89516"}, - {file = "psycopg2-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:426f9f29bde126913a20a96ff8ce7d73fd8a216cfb323b1f04da402d452853c3"}, - {file = "psycopg2-2.9.9-cp311-cp311-win32.whl", hash = "sha256:ade01303ccf7ae12c356a5e10911c9e1c51136003a9a1d92f7aa9d010fb98372"}, - {file = "psycopg2-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981"}, - {file = "psycopg2-2.9.9-cp312-cp312-win32.whl", hash = "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024"}, - {file = "psycopg2-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693"}, - {file = "psycopg2-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:5e0d98cade4f0e0304d7d6f25bbfbc5bd186e07b38eac65379309c4ca3193efa"}, - {file = "psycopg2-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:7e2dacf8b009a1c1e843b5213a87f7c544b2b042476ed7755be813eaf4e8347a"}, - {file = "psycopg2-2.9.9-cp38-cp38-win32.whl", hash = "sha256:ff432630e510709564c01dafdbe996cb552e0b9f3f065eb89bdce5bd31fabf4c"}, - {file = "psycopg2-2.9.9-cp38-cp38-win_amd64.whl", hash = "sha256:bac58c024c9922c23550af2a581998624d6e02350f4ae9c5f0bc642c633a2d5e"}, - {file = "psycopg2-2.9.9-cp39-cp39-win32.whl", hash = "sha256:c92811b2d4c9b6ea0285942b2e7cac98a59e166d59c588fe5cfe1eda58e72d59"}, - {file = "psycopg2-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:de80739447af31525feddeb8effd640782cf5998e1a4e9192ebdf829717e3913"}, - {file = "psycopg2-2.9.9.tar.gz", hash = "sha256:d1454bde93fb1e224166811694d600e746430c006fbb031ea06ecc2ea41bf156"}, + {file = "psycopg2-binary-2.9.9.tar.gz", hash = "sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c2470da5418b76232f02a2fcd2229537bb2d5a7096674ce61859c3229f2eb202"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c6af2a6d4b7ee9615cbb162b0738f6e1fd1f5c3eda7e5da17861eacf4c717ea7"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:75723c3c0fbbf34350b46a3199eb50638ab22a0228f93fb472ef4d9becc2382b"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:83791a65b51ad6ee6cf0845634859d69a038ea9b03d7b26e703f94c7e93dbcf9"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0ef4854e82c09e84cc63084a9e4ccd6d9b154f1dbdd283efb92ecd0b5e2b8c84"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed1184ab8f113e8d660ce49a56390ca181f2981066acc27cf637d5c1e10ce46e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d2997c458c690ec2bc6b0b7ecbafd02b029b7b4283078d3b32a852a7ce3ddd98"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b58b4710c7f4161b5e9dcbe73bb7c62d65670a87df7bcce9e1faaad43e715245"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:0c009475ee389757e6e34611d75f6e4f05f0cf5ebb76c6037508318e1a1e0d7e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8dbf6d1bc73f1d04ec1734bae3b4fb0ee3cb2a493d35ede9badbeb901fb40f6f"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win32.whl", hash = "sha256:3f78fd71c4f43a13d342be74ebbc0666fe1f555b8837eb113cb7416856c79682"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:876801744b0dee379e4e3c38b76fc89f88834bb15bf92ee07d94acd06ec890a0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ee825e70b1a209475622f7f7b776785bd68f34af6e7a46e2e42f27b659b5bc26"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1ea665f8ce695bcc37a90ee52de7a7980be5161375d42a0b6c6abedbf0d81f0f"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:143072318f793f53819048fdfe30c321890af0c3ec7cb1dfc9cc87aa88241de2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c332c8d69fb64979ebf76613c66b985414927a40f8defa16cf1bc028b7b0a7b0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f7fc5a5acafb7d6ccca13bfa8c90f8c51f13d8fb87d95656d3950f0158d3ce53"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:977646e05232579d2e7b9c59e21dbe5261f403a88417f6a6512e70d3f8a046be"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b6356793b84728d9d50ead16ab43c187673831e9d4019013f1402c41b1db9b27"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bc7bb56d04601d443f24094e9e31ae6deec9ccb23581f75343feebaf30423359"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:77853062a2c45be16fd6b8d6de2a99278ee1d985a7bd8b103e97e41c034006d2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:78151aa3ec21dccd5cdef6c74c3e73386dcdfaf19bced944169697d7ac7482fc"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win32.whl", hash = "sha256:dc4926288b2a3e9fd7b50dc6a1909a13bbdadfc67d93f3374d984e56f885579d"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:b76bedd166805480ab069612119ea636f5ab8f8771e640ae103e05a4aae3e417"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b0605eaed3eb239e87df0d5e3c6489daae3f7388d455d0c0b4df899519c6a38d"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f8544b092a29a6ddd72f3556a9fcf249ec412e10ad28be6a0c0d948924f2212"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2d423c8d8a3c82d08fe8af900ad5b613ce3632a1249fd6a223941d0735fce493"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2e5afae772c00980525f6d6ecf7cbca55676296b580c0e6abb407f15f3706996"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e6f98446430fdf41bd36d4faa6cb409f5140c1c2cf58ce0bbdaf16af7d3f119"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c77e3d1862452565875eb31bdb45ac62502feabbd53429fdc39a1cc341d681ba"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:cb16c65dcb648d0a43a2521f2f0a2300f40639f6f8c1ecbc662141e4e3e1ee07"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:911dda9c487075abd54e644ccdf5e5c16773470a6a5d3826fda76699410066fb"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win32.whl", hash = "sha256:64cf30263844fa208851ebb13b0732ce674d8ec6a0c86a4e160495d299ba3c93"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:81ff62668af011f9a48787564ab7eded4e9fb17a4a6a74af5ffa6a457400d2ab"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2293b001e319ab0d869d660a704942c9e2cce19745262a8aba2115ef41a0a42a"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:03ef7df18daf2c4c07e2695e8cfd5ee7f748a1d54d802330985a78d2a5a6dca9"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a602ea5aff39bb9fac6308e9c9d82b9a35c2bf288e184a816002c9fae930b77"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8359bf4791968c5a78c56103702000105501adb557f3cf772b2c207284273984"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:275ff571376626195ab95a746e6a04c7df8ea34638b99fc11160de91f2fef503"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f9b5571d33660d5009a8b3c25dc1db560206e2d2f89d3df1cb32d72c0d117d52"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:420f9bbf47a02616e8554e825208cb947969451978dceb77f95ad09c37791dae"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:4154ad09dac630a0f13f37b583eae260c6aa885d67dfbccb5b02c33f31a6d420"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:a148c5d507bb9b4f2030a2025c545fccb0e1ef317393eaba42e7eabd28eb6041"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:68fc1f1ba168724771e38bee37d940d2865cb0f562380a1fb1ffb428b75cb692"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:281309265596e388ef483250db3640e5f414168c5a67e9c665cafce9492eda2f"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:60989127da422b74a04345096c10d416c2b41bd7bf2a380eb541059e4e999980"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:246b123cc54bb5361588acc54218c8c9fb73068bf227a4a531d8ed56fa3ca7d6"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:34eccd14566f8fe14b2b95bb13b11572f7c7d5c36da61caf414d23b91fcc5d94"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18d0ef97766055fec15b5de2c06dd8e7654705ce3e5e5eed3b6651a1d2a9a152"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d3f82c171b4ccd83bbaf35aa05e44e690113bd4f3b7b6cc54d2219b132f3ae55"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ead20f7913a9c1e894aebe47cccf9dc834e1618b7aa96155d2091a626e59c972"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ca49a8119c6cbd77375ae303b0cfd8c11f011abbbd64601167ecca18a87e7cdd"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:323ba25b92454adb36fa425dc5cf6f8f19f78948cbad2e7bc6cdf7b0d7982e59"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:1236ed0952fbd919c100bc839eaa4a39ebc397ed1c08a97fc45fee2a595aa1b3"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:729177eaf0aefca0994ce4cffe96ad3c75e377c7b6f4efa59ebf003b6d398716"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win32.whl", hash = "sha256:804d99b24ad523a1fe18cc707bf741670332f7c7412e9d49cb5eab67e886b9b5"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win_amd64.whl", hash = "sha256:a6cdcc3ede532f4a4b96000b6362099591ab4a3e913d70bcbac2b56c872446f7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:72dffbd8b4194858d0941062a9766f8297e8868e1dd07a7b36212aaa90f49472"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:30dcc86377618a4c8f3b72418df92e77be4254d8f89f14b8e8f57d6d43603c0f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:31a34c508c003a4347d389a9e6fcc2307cc2150eb516462a7a17512130de109e"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:15208be1c50b99203fe88d15695f22a5bed95ab3f84354c494bcb1d08557df67"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1873aade94b74715be2246321c8650cabf5a0d098a95bab81145ffffa4c13876"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a58c98a7e9c021f357348867f537017057c2ed7f77337fd914d0bedb35dace7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4686818798f9194d03c9129a4d9a702d9e113a89cb03bffe08c6cf799e053291"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:ebdc36bea43063116f0486869652cb2ed7032dbc59fbcb4445c4862b5c1ecf7f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:ca08decd2697fdea0aea364b370b1249d47336aec935f87b8bbfd7da5b2ee9c1"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ac05fb791acf5e1a3e39402641827780fe44d27e72567a000412c648a85ba860"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win32.whl", hash = "sha256:9dba73be7305b399924709b91682299794887cbbd88e38226ed9f6712eabee90"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:f7ae5d65ccfbebdfa761585228eb4d0df3a8b15cfb53bd953e713e09fbb12957"}, ] [[package]] @@ -390,13 +449,13 @@ cli = ["click (>=5.0)"] [[package]] name = "requests" -version = "2.32.2" +version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" files = [ - {file = "requests-2.32.2-py3-none-any.whl", hash = "sha256:fc06670dd0ed212426dfeb94fc1b983d917c4f9847c863f313c9dfaaffb7c23c"}, - {file = "requests-2.32.2.tar.gz", hash = "sha256:dd951ff5ecf3e3b3aa26b40703ba77495dab41da839ae72ef3c8e5d8e2433289"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -494,4 +553,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "470159f92c63a9db1bc186d9da1a7fd1c579103ae33a346bb3484114c047d445" +content-hash = "692728c2cf70ba9214712bdec40930c9f5680e07a1ffc39b71d6ebb71c0f0817" diff --git a/pyproject.toml b/back/pyproject.toml similarity index 68% rename from pyproject.toml rename to back/pyproject.toml index 76cf2c8..2ba9906 100644 --- a/pyproject.toml +++ b/back/pyproject.toml @@ -2,15 +2,14 @@ name = "back" version = "0.1.0" description = "" -authors = ["k.mikhailova@svs-tech.pro"] +authors = ["Ksenia Miqhailova "] readme = "readme.md" -package-mode = false [tool.poetry.dependencies] python = "^3.10" Django = "^5.0.6" djangorestframework = "^3.15.1" -psycopg2 = "^2.9.9" +psycopg2-binary = "^2.9.9" markdown = "^3.6" django-filter = "^24.2" pillow = "^10.3.0" @@ -26,5 +25,5 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.taskipy.tasks] -migrate = "cd back && python manage.py makemigrations && python manage.py migrate" -server = "cd back && python manage.py runserver 0.0.0.0:8000" \ No newline at end of file +migrate = "python manage.py makemigrations && python manage.py migrate" +server = "python manage.py runserver 0.0.0.0:8000" \ No newline at end of file diff --git a/compose-dev.yaml b/compose-dev.yaml new file mode 100644 index 0000000..cc7fd0a --- /dev/null +++ b/compose-dev.yaml @@ -0,0 +1,12 @@ +services: + app: + entrypoint: + - sleep + - infinity + image: docker/dev-environments-javascript:stable-1 + init: true + volumes: + - type: bind + source: /var/run/docker.sock + target: /var/run/docker.sock + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1431309 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,55 @@ +services: + back: + build: + context: ./back + dockerfile: Dockerfile + container_name: toinv-back + restart: always + expose: + - "8000" + # healthcheck: + # test: curl -f http://localhost:8000/ || exit 1 + # interval: 5s + # timeout: 3s + volumes: + - ./.env:/app/.env + networks: + - toinv-network + image: ci.svs-tech.pro/toinv_back:latest + + front: + build: + context: ./front + dockerfile: Dockerfile + container_name: toinv-front + restart: always + expose: + - "4173" + # depends_on: + # back: + # condition: service_healthy + networks: + - toinv-network + image: ci.svs-tech.pro/toinv_front:latest + + nginx: + image: ci.svs-tech.pro/nginx:1.25 + container_name: toinv-nginx + restart: always + ports: + - "80:80" + # depends_on: + # back: + # condition: service_healthy + links: + - back:back + - front:front + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf + - ./nginx/conf.d:/etc/nginx/conf.d + networks: + - toinv-network + +networks: + toinv-network: + driver: bridge diff --git a/front/Dockerfile b/front/Dockerfile new file mode 100644 index 0000000..1c08803 --- /dev/null +++ b/front/Dockerfile @@ -0,0 +1,12 @@ +FROM ci.svs-tech.pro/library/node:21 + +RUN mkdir -p /src + +COPY package.json src/package.json + +WORKDIR /src +RUN npm install --omit=dev + +COPY . /src +RUN npm run build +CMD npm run preview -- --host \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..473a00c --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,90 @@ +user root; +worker_processes auto; +error_log /var/log/nginx/error.log; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + upstream django { + server back:8000; + keepalive 16; + } + + server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://front:4173; + proxy_set_header Host $host:$server_port; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + location /api/ { + proxy_pass http://back:8000/api/; + } + + location /make_qr_report { + proxy_pass http://back:8000/make_qr_report; + } + location /qr_reader { + proxy_pass http://back:8000/qr_reader; + } + + location /admin/ { + proxy_pass http://back:8000/admin/; + } + location /static/admin/ { + proxy_pass http://back:8000/static/admin/; + } + + location /ws { + proxy_pass http://back:8000/ws; + proxy_http_version 1.1; + proxy_set_header Host $server_name:$server_port; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection Upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name:$server_port; + } + location /maintenance { + proxy_pass http://back:8000/maintenance; + proxy_http_version 1.1; + proxy_set_header Host $server_name:$server_port; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection Upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name:$server_port; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +} From cf9998c5f99fc9e7350971c2b4b7cc42ed1b3ccb Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 3 Jun 2024 13:34:54 +0300 Subject: [PATCH 06/13] docker nuxt front --- back/Dockerfile | 2 +- back/api/settings.py | 3 ++- docker-compose.yml | 2 +- nginx/nginx.conf | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/back/Dockerfile b/back/Dockerfile index 86dd8b8..4dd2abc 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -14,4 +14,4 @@ RUN poetry install COPY . ${WORKING_DIR} -CMD ["poetry", "run", "python", "manage.py", "runserver"] +CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/back/api/settings.py b/back/api/settings.py index 0c43fc7..b327f84 100644 --- a/back/api/settings.py +++ b/back/api/settings.py @@ -29,7 +29,8 @@ SECRET_KEY = "django-insecure-ruo!wst&sb8(f9)j5u4rda-w!673lj_-c0a%gx_t@)ff*q*2ze DEBUG = True ALLOWED_HOSTS = [ - '192.168.103.159' + '192.168.103.159', + 'back', ] CORS_ALLOWED_ORIGINS = [ 'http://localhost:3000', diff --git a/docker-compose.yml b/docker-compose.yml index 1431309..5b48236 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: container_name: toinv-front restart: always expose: - - "4173" + - "3000" # depends_on: # back: # condition: service_healthy diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 473a00c..bac367b 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -37,7 +37,7 @@ http { server_name localhost; location / { - proxy_pass http://front:4173; + proxy_pass http://front:3000; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 0c95cda20df6c4a56d33eae0ab9318242d50cc08 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 3 Jun 2024 13:49:16 +0300 Subject: [PATCH 07/13] api nginx --- nginx/nginx.conf | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index bac367b..21cf4a9 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -44,14 +44,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } location /api/ { - proxy_pass http://back:8000/api/; - } - - location /make_qr_report { - proxy_pass http://back:8000/make_qr_report; - } - location /qr_reader { - proxy_pass http://back:8000/qr_reader; + proxy_pass http://back:8000/; } location /admin/ { @@ -61,27 +54,6 @@ http { proxy_pass http://back:8000/static/admin/; } - location /ws { - proxy_pass http://back:8000/ws; - proxy_http_version 1.1; - proxy_set_header Host $server_name:$server_port; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection Upgrade; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name:$server_port; - } - location /maintenance { - proxy_pass http://back:8000/maintenance; - proxy_http_version 1.1; - proxy_set_header Host $server_name:$server_port; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection Upgrade; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name:$server_port; - } - error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; From 61d6823e5f30e688709cce316a06f2a9ed0dbf24 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 3 Jun 2024 13:49:38 +0300 Subject: [PATCH 08/13] api nginx --- front/nuxt.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/nuxt.config.ts b/front/nuxt.config.ts index f542f73..3f65c32 100644 --- a/front/nuxt.config.ts +++ b/front/nuxt.config.ts @@ -5,7 +5,7 @@ export default defineNuxtConfig({ modules: ["@nuxt/ui", "nuxt-svgo"], runtimeConfig: { public: { - apiBase: '', + apiBase: '/api', }, }, }) \ No newline at end of file From 28406ad98a5e3521e4f169ec25a3aee50955ebed Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 3 Jun 2024 15:30:02 +0300 Subject: [PATCH 09/13] docker fix --- back/api/urls.py | 6 +++--- nginx/nginx.conf | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/back/api/urls.py b/back/api/urls.py index 22677de..906debf 100644 --- a/back/api/urls.py +++ b/back/api/urls.py @@ -21,9 +21,9 @@ from rest_framework import routers from inventory import views router = routers.DefaultRouter() -router.register(r'partner', views.PartnerViewSet) -router.register(r'element', views.ElementViewSet) -router.register(r'inventory', views.InventoryItemViewSet) +router.register(r'api/partner', views.PartnerViewSet) +router.register(r'api/element', views.ElementViewSet) +router.register(r'api/inventory', views.InventoryItemViewSet) urlpatterns = [ path('', include(router.urls)), diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 21cf4a9..6b31256 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -44,7 +44,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } location /api/ { - proxy_pass http://back:8000/; + proxy_pass http://back:8000/api/; } location /admin/ { From 7bdf4c628dc4745d471fc9181ab45132303e5f4e Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 3 Jun 2024 16:01:05 +0300 Subject: [PATCH 10/13] styleS --- front/components/edit.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/components/edit.vue b/front/components/edit.vue index 853a292..8405ec3 100644 --- a/front/components/edit.vue +++ b/front/components/edit.vue @@ -141,7 +141,7 @@ onMounted(async () => {