From b07fef8b44f9f9290af9a8895301952b9af9de3f Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 07:11:59 -0300 Subject: [PATCH 01/12] App no ar montando o volume --- Dockerfile | 15 ++++++++------- .env.example => application/.env.example | 0 .flake8 => application/.flake8 | 0 {ai => application/ai}/__init__.py | 0 {ai => application/ai}/admin.py | 0 {ai => application/ai}/agent.py | 0 {ai => application/ai}/apps.py | 0 {ai => application/ai}/management/__init__.py | 0 .../ai}/management/commands/__init__.py | 0 .../ai}/management/commands/sge_agent_invoke.py | 0 {ai => application/ai}/migrations/0001_initial.py | 0 {ai => application/ai}/migrations/__init__.py | 0 {ai => application/ai}/models.py | 0 {ai => application/ai}/prompts.py | 0 {app => application/app}/__init__.py | 0 {app => application/app}/asgi.py | 0 {app => application/app}/metrics.py | 0 {app => application/app}/settings.py | 0 {app => application/app}/templates/base.html | 0 .../app}/templates/components/_ai_result.html | 0 .../app}/templates/components/_footer.html | 0 .../app}/templates/components/_header.html | 0 .../app}/templates/components/_pagination.html | 0 .../templates/components/_product_metrics.html | 0 .../app}/templates/components/_sales_metrics.html | 0 .../app}/templates/components/_sidebar.html | 0 {app => application/app}/templates/home.html | 0 .../app}/templates/registration/login.html | 0 {app => application/app}/urls.py | 0 {app => application/app}/views.py | 0 {app => application/app}/wsgi.py | 0 .../authentication}/__init__.py | 0 .../authentication}/apps.py | 0 .../authentication}/migrations/__init__.py | 0 .../authentication}/urls.py | 0 {brands => application/brands}/__init__.py | 0 {brands => application/brands}/admin.py | 0 {brands => application/brands}/apps.py | 0 {brands => application/brands}/forms.py | 0 .../brands}/migrations/0001_initial.py | 0 .../brands}/migrations/__init__.py | 0 {brands => application/brands}/models.py | 0 {brands => application/brands}/serializers.py | 0 .../brands}/templates/brand_create.html | 0 .../brands}/templates/brand_delete.html | 0 .../brands}/templates/brand_detail.html | 0 .../brands}/templates/brand_list.html | 0 .../brands}/templates/brand_update.html | 0 {brands => application/brands}/urls.py | 0 {brands => application/brands}/views.py | 0 .../categories}/__init__.py | 0 {categories => application/categories}/admin.py | 0 {categories => application/categories}/apps.py | 0 {categories => application/categories}/forms.py | 0 .../categories}/migrations/0001_initial.py | 0 .../categories}/migrations/__init__.py | 0 {categories => application/categories}/models.py | 0 .../categories}/serializers.py | 0 .../categories}/templates/category_create.html | 0 .../categories}/templates/category_delete.html | 0 .../categories}/templates/category_detail.html | 0 .../categories}/templates/category_list.html | 0 .../categories}/templates/category_update.html | 0 {categories => application/categories}/urls.py | 0 {categories => application/categories}/views.py | 0 cron => application/cron | 0 {inflows => application/inflows}/__init__.py | 0 {inflows => application/inflows}/admin.py | 0 {inflows => application/inflows}/apps.py | 0 {inflows => application/inflows}/forms.py | 0 .../inflows}/migrations/0001_initial.py | 0 .../inflows}/migrations/__init__.py | 0 {inflows => application/inflows}/models.py | 0 {inflows => application/inflows}/serializers.py | 0 {inflows => application/inflows}/signals.py | 0 .../inflows}/templates/inflow_create.html | 0 .../inflows}/templates/inflow_detail.html | 0 .../inflows}/templates/inflow_list.html | 0 {inflows => application/inflows}/urls.py | 0 {inflows => application/inflows}/views.py | 0 manage.py => application/manage.py | 0 {outflows => application/outflows}/__init__.py | 0 {outflows => application/outflows}/admin.py | 0 {outflows => application/outflows}/apps.py | 0 {outflows => application/outflows}/forms.py | 0 .../outflows}/migrations/0001_initial.py | 0 .../outflows}/migrations/__init__.py | 0 {outflows => application/outflows}/models.py | 0 {outflows => application/outflows}/serializers.py | 0 {outflows => application/outflows}/signals.py | 0 .../outflows}/templates/outflow_create.html | 0 .../outflows}/templates/outflow_detail.html | 0 .../outflows}/templates/outflow_list.html | 0 {outflows => application/outflows}/urls.py | 0 {outflows => application/outflows}/views.py | 0 {products => application/products}/__init__.py | 0 {products => application/products}/admin.py | 0 {products => application/products}/apps.py | 0 {products => application/products}/forms.py | 0 .../products}/management/__init__.py | 0 .../products}/management/commands/__init__.py | 0 .../products}/management/commands/fazer_coisas.py | 0 .../products}/migrations/0001_initial.py | 0 .../products}/migrations/__init__.py | 0 {products => application/products}/models.py | 0 {products => application/products}/serializers.py | 0 .../products}/templates/product_create.html | 0 .../products}/templates/product_delete.html | 0 .../products}/templates/product_detail.html | 0 .../products}/templates/product_list.html | 0 .../products}/templates/product_update.html | 0 {products => application/products}/urls.py | 0 {products => application/products}/views.py | 0 requirements.txt => application/requirements.txt | 0 .../requirements_dev.txt | 0 {suppliers => application/suppliers}/__init__.py | 0 {suppliers => application/suppliers}/admin.py | 0 {suppliers => application/suppliers}/apps.py | 0 {suppliers => application/suppliers}/forms.py | 0 .../suppliers}/migrations/0001_initial.py | 0 .../suppliers}/migrations/__init__.py | 0 {suppliers => application/suppliers}/models.py | 0 .../suppliers}/serializers.py | 0 .../suppliers}/templates/supplier_create.html | 0 .../suppliers}/templates/supplier_delete.html | 0 .../suppliers}/templates/supplier_detail.html | 0 .../suppliers}/templates/supplier_list.html | 0 .../suppliers}/templates/supplier_update.html | 0 {suppliers => application/suppliers}/urls.py | 0 {suppliers => application/suppliers}/views.py | 0 docker-compose.yml | 4 +++- 131 files changed, 11 insertions(+), 8 deletions(-) rename .env.example => application/.env.example (100%) rename .flake8 => application/.flake8 (100%) rename {ai => application/ai}/__init__.py (100%) rename {ai => application/ai}/admin.py (100%) rename {ai => application/ai}/agent.py (100%) rename {ai => application/ai}/apps.py (100%) rename {ai => application/ai}/management/__init__.py (100%) rename {ai => application/ai}/management/commands/__init__.py (100%) rename {ai => application/ai}/management/commands/sge_agent_invoke.py (100%) rename {ai => application/ai}/migrations/0001_initial.py (100%) rename {ai => application/ai}/migrations/__init__.py (100%) rename {ai => application/ai}/models.py (100%) rename {ai => application/ai}/prompts.py (100%) rename {app => application/app}/__init__.py (100%) rename {app => application/app}/asgi.py (100%) rename {app => application/app}/metrics.py (100%) rename {app => application/app}/settings.py (100%) rename {app => application/app}/templates/base.html (100%) rename {app => application/app}/templates/components/_ai_result.html (100%) rename {app => application/app}/templates/components/_footer.html (100%) rename {app => application/app}/templates/components/_header.html (100%) rename {app => application/app}/templates/components/_pagination.html (100%) rename {app => application/app}/templates/components/_product_metrics.html (100%) rename {app => application/app}/templates/components/_sales_metrics.html (100%) rename {app => application/app}/templates/components/_sidebar.html (100%) rename {app => application/app}/templates/home.html (100%) rename {app => application/app}/templates/registration/login.html (100%) rename {app => application/app}/urls.py (100%) rename {app => application/app}/views.py (100%) rename {app => application/app}/wsgi.py (100%) rename {authentication => application/authentication}/__init__.py (100%) rename {authentication => application/authentication}/apps.py (100%) rename {authentication => application/authentication}/migrations/__init__.py (100%) rename {authentication => application/authentication}/urls.py (100%) rename {brands => application/brands}/__init__.py (100%) rename {brands => application/brands}/admin.py (100%) rename {brands => application/brands}/apps.py (100%) rename {brands => application/brands}/forms.py (100%) rename {brands => application/brands}/migrations/0001_initial.py (100%) rename {brands => application/brands}/migrations/__init__.py (100%) rename {brands => application/brands}/models.py (100%) rename {brands => application/brands}/serializers.py (100%) rename {brands => application/brands}/templates/brand_create.html (100%) rename {brands => application/brands}/templates/brand_delete.html (100%) rename {brands => application/brands}/templates/brand_detail.html (100%) rename {brands => application/brands}/templates/brand_list.html (100%) rename {brands => application/brands}/templates/brand_update.html (100%) rename {brands => application/brands}/urls.py (100%) rename {brands => application/brands}/views.py (100%) rename {categories => application/categories}/__init__.py (100%) rename {categories => application/categories}/admin.py (100%) rename {categories => application/categories}/apps.py (100%) rename {categories => application/categories}/forms.py (100%) rename {categories => application/categories}/migrations/0001_initial.py (100%) rename {categories => application/categories}/migrations/__init__.py (100%) rename {categories => application/categories}/models.py (100%) rename {categories => application/categories}/serializers.py (100%) rename {categories => application/categories}/templates/category_create.html (100%) rename {categories => application/categories}/templates/category_delete.html (100%) rename {categories => application/categories}/templates/category_detail.html (100%) rename {categories => application/categories}/templates/category_list.html (100%) rename {categories => application/categories}/templates/category_update.html (100%) rename {categories => application/categories}/urls.py (100%) rename {categories => application/categories}/views.py (100%) rename cron => application/cron (100%) rename {inflows => application/inflows}/__init__.py (100%) rename {inflows => application/inflows}/admin.py (100%) rename {inflows => application/inflows}/apps.py (100%) rename {inflows => application/inflows}/forms.py (100%) rename {inflows => application/inflows}/migrations/0001_initial.py (100%) rename {inflows => application/inflows}/migrations/__init__.py (100%) rename {inflows => application/inflows}/models.py (100%) rename {inflows => application/inflows}/serializers.py (100%) rename {inflows => application/inflows}/signals.py (100%) rename {inflows => application/inflows}/templates/inflow_create.html (100%) rename {inflows => application/inflows}/templates/inflow_detail.html (100%) rename {inflows => application/inflows}/templates/inflow_list.html (100%) rename {inflows => application/inflows}/urls.py (100%) rename {inflows => application/inflows}/views.py (100%) rename manage.py => application/manage.py (100%) rename {outflows => application/outflows}/__init__.py (100%) rename {outflows => application/outflows}/admin.py (100%) rename {outflows => application/outflows}/apps.py (100%) rename {outflows => application/outflows}/forms.py (100%) rename {outflows => application/outflows}/migrations/0001_initial.py (100%) rename {outflows => application/outflows}/migrations/__init__.py (100%) rename {outflows => application/outflows}/models.py (100%) rename {outflows => application/outflows}/serializers.py (100%) rename {outflows => application/outflows}/signals.py (100%) rename {outflows => application/outflows}/templates/outflow_create.html (100%) rename {outflows => application/outflows}/templates/outflow_detail.html (100%) rename {outflows => application/outflows}/templates/outflow_list.html (100%) rename {outflows => application/outflows}/urls.py (100%) rename {outflows => application/outflows}/views.py (100%) rename {products => application/products}/__init__.py (100%) rename {products => application/products}/admin.py (100%) rename {products => application/products}/apps.py (100%) rename {products => application/products}/forms.py (100%) rename {products => application/products}/management/__init__.py (100%) rename {products => application/products}/management/commands/__init__.py (100%) rename {products => application/products}/management/commands/fazer_coisas.py (100%) rename {products => application/products}/migrations/0001_initial.py (100%) rename {products => application/products}/migrations/__init__.py (100%) rename {products => application/products}/models.py (100%) rename {products => application/products}/serializers.py (100%) rename {products => application/products}/templates/product_create.html (100%) rename {products => application/products}/templates/product_delete.html (100%) rename {products => application/products}/templates/product_detail.html (100%) rename {products => application/products}/templates/product_list.html (100%) rename {products => application/products}/templates/product_update.html (100%) rename {products => application/products}/urls.py (100%) rename {products => application/products}/views.py (100%) rename requirements.txt => application/requirements.txt (100%) rename requirements_dev.txt => application/requirements_dev.txt (100%) rename {suppliers => application/suppliers}/__init__.py (100%) rename {suppliers => application/suppliers}/admin.py (100%) rename {suppliers => application/suppliers}/apps.py (100%) rename {suppliers => application/suppliers}/forms.py (100%) rename {suppliers => application/suppliers}/migrations/0001_initial.py (100%) rename {suppliers => application/suppliers}/migrations/__init__.py (100%) rename {suppliers => application/suppliers}/models.py (100%) rename {suppliers => application/suppliers}/serializers.py (100%) rename {suppliers => application/suppliers}/templates/supplier_create.html (100%) rename {suppliers => application/suppliers}/templates/supplier_delete.html (100%) rename {suppliers => application/suppliers}/templates/supplier_detail.html (100%) rename {suppliers => application/suppliers}/templates/supplier_list.html (100%) rename {suppliers => application/suppliers}/templates/supplier_update.html (100%) rename {suppliers => application/suppliers}/urls.py (100%) rename {suppliers => application/suppliers}/views.py (100%) diff --git a/Dockerfile b/Dockerfile index 55940667..dd6f8e07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,17 +5,18 @@ WORKDIR /sge ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 -RUN apt update && apt -y install cron && apt -y install nano - -COPY . . +RUN apt update && apt -y install cron && apt -y install vim +# COPY ./application . +COPY ./application/requirements.txt /requirements.txt RUN pip install --upgrade pip -RUN pip install -r requirements.txt +RUN pip install -r /requirements.txt -COPY ./cron /etc/cron.d/cron -RUN chmod 0644 /etc/cron.d/cron -RUN crontab /etc/cron.d/cron +# COPY ./application/cron /etc/cron.d/cron +# RUN chmod 0644 /etc/cron.d/cron +# RUN crontab /etc/cron.d/cron EXPOSE 8000 CMD cron ; python manage.py migrate && python manage.py runserver 0.0.0.0:8000 +#CMD tail -f /dev/null diff --git a/.env.example b/application/.env.example similarity index 100% rename from .env.example rename to application/.env.example diff --git a/.flake8 b/application/.flake8 similarity index 100% rename from .flake8 rename to application/.flake8 diff --git a/ai/__init__.py b/application/ai/__init__.py similarity index 100% rename from ai/__init__.py rename to application/ai/__init__.py diff --git a/ai/admin.py b/application/ai/admin.py similarity index 100% rename from ai/admin.py rename to application/ai/admin.py diff --git a/ai/agent.py b/application/ai/agent.py similarity index 100% rename from ai/agent.py rename to application/ai/agent.py diff --git a/ai/apps.py b/application/ai/apps.py similarity index 100% rename from ai/apps.py rename to application/ai/apps.py diff --git a/ai/management/__init__.py b/application/ai/management/__init__.py similarity index 100% rename from ai/management/__init__.py rename to application/ai/management/__init__.py diff --git a/ai/management/commands/__init__.py b/application/ai/management/commands/__init__.py similarity index 100% rename from ai/management/commands/__init__.py rename to application/ai/management/commands/__init__.py diff --git a/ai/management/commands/sge_agent_invoke.py b/application/ai/management/commands/sge_agent_invoke.py similarity index 100% rename from ai/management/commands/sge_agent_invoke.py rename to application/ai/management/commands/sge_agent_invoke.py diff --git a/ai/migrations/0001_initial.py b/application/ai/migrations/0001_initial.py similarity index 100% rename from ai/migrations/0001_initial.py rename to application/ai/migrations/0001_initial.py diff --git a/ai/migrations/__init__.py b/application/ai/migrations/__init__.py similarity index 100% rename from ai/migrations/__init__.py rename to application/ai/migrations/__init__.py diff --git a/ai/models.py b/application/ai/models.py similarity index 100% rename from ai/models.py rename to application/ai/models.py diff --git a/ai/prompts.py b/application/ai/prompts.py similarity index 100% rename from ai/prompts.py rename to application/ai/prompts.py diff --git a/app/__init__.py b/application/app/__init__.py similarity index 100% rename from app/__init__.py rename to application/app/__init__.py diff --git a/app/asgi.py b/application/app/asgi.py similarity index 100% rename from app/asgi.py rename to application/app/asgi.py diff --git a/app/metrics.py b/application/app/metrics.py similarity index 100% rename from app/metrics.py rename to application/app/metrics.py diff --git a/app/settings.py b/application/app/settings.py similarity index 100% rename from app/settings.py rename to application/app/settings.py diff --git a/app/templates/base.html b/application/app/templates/base.html similarity index 100% rename from app/templates/base.html rename to application/app/templates/base.html diff --git a/app/templates/components/_ai_result.html b/application/app/templates/components/_ai_result.html similarity index 100% rename from app/templates/components/_ai_result.html rename to application/app/templates/components/_ai_result.html diff --git a/app/templates/components/_footer.html b/application/app/templates/components/_footer.html similarity index 100% rename from app/templates/components/_footer.html rename to application/app/templates/components/_footer.html diff --git a/app/templates/components/_header.html b/application/app/templates/components/_header.html similarity index 100% rename from app/templates/components/_header.html rename to application/app/templates/components/_header.html diff --git a/app/templates/components/_pagination.html b/application/app/templates/components/_pagination.html similarity index 100% rename from app/templates/components/_pagination.html rename to application/app/templates/components/_pagination.html diff --git a/app/templates/components/_product_metrics.html b/application/app/templates/components/_product_metrics.html similarity index 100% rename from app/templates/components/_product_metrics.html rename to application/app/templates/components/_product_metrics.html diff --git a/app/templates/components/_sales_metrics.html b/application/app/templates/components/_sales_metrics.html similarity index 100% rename from app/templates/components/_sales_metrics.html rename to application/app/templates/components/_sales_metrics.html diff --git a/app/templates/components/_sidebar.html b/application/app/templates/components/_sidebar.html similarity index 100% rename from app/templates/components/_sidebar.html rename to application/app/templates/components/_sidebar.html diff --git a/app/templates/home.html b/application/app/templates/home.html similarity index 100% rename from app/templates/home.html rename to application/app/templates/home.html diff --git a/app/templates/registration/login.html b/application/app/templates/registration/login.html similarity index 100% rename from app/templates/registration/login.html rename to application/app/templates/registration/login.html diff --git a/app/urls.py b/application/app/urls.py similarity index 100% rename from app/urls.py rename to application/app/urls.py diff --git a/app/views.py b/application/app/views.py similarity index 100% rename from app/views.py rename to application/app/views.py diff --git a/app/wsgi.py b/application/app/wsgi.py similarity index 100% rename from app/wsgi.py rename to application/app/wsgi.py diff --git a/authentication/__init__.py b/application/authentication/__init__.py similarity index 100% rename from authentication/__init__.py rename to application/authentication/__init__.py diff --git a/authentication/apps.py b/application/authentication/apps.py similarity index 100% rename from authentication/apps.py rename to application/authentication/apps.py diff --git a/authentication/migrations/__init__.py b/application/authentication/migrations/__init__.py similarity index 100% rename from authentication/migrations/__init__.py rename to application/authentication/migrations/__init__.py diff --git a/authentication/urls.py b/application/authentication/urls.py similarity index 100% rename from authentication/urls.py rename to application/authentication/urls.py diff --git a/brands/__init__.py b/application/brands/__init__.py similarity index 100% rename from brands/__init__.py rename to application/brands/__init__.py diff --git a/brands/admin.py b/application/brands/admin.py similarity index 100% rename from brands/admin.py rename to application/brands/admin.py diff --git a/brands/apps.py b/application/brands/apps.py similarity index 100% rename from brands/apps.py rename to application/brands/apps.py diff --git a/brands/forms.py b/application/brands/forms.py similarity index 100% rename from brands/forms.py rename to application/brands/forms.py diff --git a/brands/migrations/0001_initial.py b/application/brands/migrations/0001_initial.py similarity index 100% rename from brands/migrations/0001_initial.py rename to application/brands/migrations/0001_initial.py diff --git a/brands/migrations/__init__.py b/application/brands/migrations/__init__.py similarity index 100% rename from brands/migrations/__init__.py rename to application/brands/migrations/__init__.py diff --git a/brands/models.py b/application/brands/models.py similarity index 100% rename from brands/models.py rename to application/brands/models.py diff --git a/brands/serializers.py b/application/brands/serializers.py similarity index 100% rename from brands/serializers.py rename to application/brands/serializers.py diff --git a/brands/templates/brand_create.html b/application/brands/templates/brand_create.html similarity index 100% rename from brands/templates/brand_create.html rename to application/brands/templates/brand_create.html diff --git a/brands/templates/brand_delete.html b/application/brands/templates/brand_delete.html similarity index 100% rename from brands/templates/brand_delete.html rename to application/brands/templates/brand_delete.html diff --git a/brands/templates/brand_detail.html b/application/brands/templates/brand_detail.html similarity index 100% rename from brands/templates/brand_detail.html rename to application/brands/templates/brand_detail.html diff --git a/brands/templates/brand_list.html b/application/brands/templates/brand_list.html similarity index 100% rename from brands/templates/brand_list.html rename to application/brands/templates/brand_list.html diff --git a/brands/templates/brand_update.html b/application/brands/templates/brand_update.html similarity index 100% rename from brands/templates/brand_update.html rename to application/brands/templates/brand_update.html diff --git a/brands/urls.py b/application/brands/urls.py similarity index 100% rename from brands/urls.py rename to application/brands/urls.py diff --git a/brands/views.py b/application/brands/views.py similarity index 100% rename from brands/views.py rename to application/brands/views.py diff --git a/categories/__init__.py b/application/categories/__init__.py similarity index 100% rename from categories/__init__.py rename to application/categories/__init__.py diff --git a/categories/admin.py b/application/categories/admin.py similarity index 100% rename from categories/admin.py rename to application/categories/admin.py diff --git a/categories/apps.py b/application/categories/apps.py similarity index 100% rename from categories/apps.py rename to application/categories/apps.py diff --git a/categories/forms.py b/application/categories/forms.py similarity index 100% rename from categories/forms.py rename to application/categories/forms.py diff --git a/categories/migrations/0001_initial.py b/application/categories/migrations/0001_initial.py similarity index 100% rename from categories/migrations/0001_initial.py rename to application/categories/migrations/0001_initial.py diff --git a/categories/migrations/__init__.py b/application/categories/migrations/__init__.py similarity index 100% rename from categories/migrations/__init__.py rename to application/categories/migrations/__init__.py diff --git a/categories/models.py b/application/categories/models.py similarity index 100% rename from categories/models.py rename to application/categories/models.py diff --git a/categories/serializers.py b/application/categories/serializers.py similarity index 100% rename from categories/serializers.py rename to application/categories/serializers.py diff --git a/categories/templates/category_create.html b/application/categories/templates/category_create.html similarity index 100% rename from categories/templates/category_create.html rename to application/categories/templates/category_create.html diff --git a/categories/templates/category_delete.html b/application/categories/templates/category_delete.html similarity index 100% rename from categories/templates/category_delete.html rename to application/categories/templates/category_delete.html diff --git a/categories/templates/category_detail.html b/application/categories/templates/category_detail.html similarity index 100% rename from categories/templates/category_detail.html rename to application/categories/templates/category_detail.html diff --git a/categories/templates/category_list.html b/application/categories/templates/category_list.html similarity index 100% rename from categories/templates/category_list.html rename to application/categories/templates/category_list.html diff --git a/categories/templates/category_update.html b/application/categories/templates/category_update.html similarity index 100% rename from categories/templates/category_update.html rename to application/categories/templates/category_update.html diff --git a/categories/urls.py b/application/categories/urls.py similarity index 100% rename from categories/urls.py rename to application/categories/urls.py diff --git a/categories/views.py b/application/categories/views.py similarity index 100% rename from categories/views.py rename to application/categories/views.py diff --git a/cron b/application/cron similarity index 100% rename from cron rename to application/cron diff --git a/inflows/__init__.py b/application/inflows/__init__.py similarity index 100% rename from inflows/__init__.py rename to application/inflows/__init__.py diff --git a/inflows/admin.py b/application/inflows/admin.py similarity index 100% rename from inflows/admin.py rename to application/inflows/admin.py diff --git a/inflows/apps.py b/application/inflows/apps.py similarity index 100% rename from inflows/apps.py rename to application/inflows/apps.py diff --git a/inflows/forms.py b/application/inflows/forms.py similarity index 100% rename from inflows/forms.py rename to application/inflows/forms.py diff --git a/inflows/migrations/0001_initial.py b/application/inflows/migrations/0001_initial.py similarity index 100% rename from inflows/migrations/0001_initial.py rename to application/inflows/migrations/0001_initial.py diff --git a/inflows/migrations/__init__.py b/application/inflows/migrations/__init__.py similarity index 100% rename from inflows/migrations/__init__.py rename to application/inflows/migrations/__init__.py diff --git a/inflows/models.py b/application/inflows/models.py similarity index 100% rename from inflows/models.py rename to application/inflows/models.py diff --git a/inflows/serializers.py b/application/inflows/serializers.py similarity index 100% rename from inflows/serializers.py rename to application/inflows/serializers.py diff --git a/inflows/signals.py b/application/inflows/signals.py similarity index 100% rename from inflows/signals.py rename to application/inflows/signals.py diff --git a/inflows/templates/inflow_create.html b/application/inflows/templates/inflow_create.html similarity index 100% rename from inflows/templates/inflow_create.html rename to application/inflows/templates/inflow_create.html diff --git a/inflows/templates/inflow_detail.html b/application/inflows/templates/inflow_detail.html similarity index 100% rename from inflows/templates/inflow_detail.html rename to application/inflows/templates/inflow_detail.html diff --git a/inflows/templates/inflow_list.html b/application/inflows/templates/inflow_list.html similarity index 100% rename from inflows/templates/inflow_list.html rename to application/inflows/templates/inflow_list.html diff --git a/inflows/urls.py b/application/inflows/urls.py similarity index 100% rename from inflows/urls.py rename to application/inflows/urls.py diff --git a/inflows/views.py b/application/inflows/views.py similarity index 100% rename from inflows/views.py rename to application/inflows/views.py diff --git a/manage.py b/application/manage.py similarity index 100% rename from manage.py rename to application/manage.py diff --git a/outflows/__init__.py b/application/outflows/__init__.py similarity index 100% rename from outflows/__init__.py rename to application/outflows/__init__.py diff --git a/outflows/admin.py b/application/outflows/admin.py similarity index 100% rename from outflows/admin.py rename to application/outflows/admin.py diff --git a/outflows/apps.py b/application/outflows/apps.py similarity index 100% rename from outflows/apps.py rename to application/outflows/apps.py diff --git a/outflows/forms.py b/application/outflows/forms.py similarity index 100% rename from outflows/forms.py rename to application/outflows/forms.py diff --git a/outflows/migrations/0001_initial.py b/application/outflows/migrations/0001_initial.py similarity index 100% rename from outflows/migrations/0001_initial.py rename to application/outflows/migrations/0001_initial.py diff --git a/outflows/migrations/__init__.py b/application/outflows/migrations/__init__.py similarity index 100% rename from outflows/migrations/__init__.py rename to application/outflows/migrations/__init__.py diff --git a/outflows/models.py b/application/outflows/models.py similarity index 100% rename from outflows/models.py rename to application/outflows/models.py diff --git a/outflows/serializers.py b/application/outflows/serializers.py similarity index 100% rename from outflows/serializers.py rename to application/outflows/serializers.py diff --git a/outflows/signals.py b/application/outflows/signals.py similarity index 100% rename from outflows/signals.py rename to application/outflows/signals.py diff --git a/outflows/templates/outflow_create.html b/application/outflows/templates/outflow_create.html similarity index 100% rename from outflows/templates/outflow_create.html rename to application/outflows/templates/outflow_create.html diff --git a/outflows/templates/outflow_detail.html b/application/outflows/templates/outflow_detail.html similarity index 100% rename from outflows/templates/outflow_detail.html rename to application/outflows/templates/outflow_detail.html diff --git a/outflows/templates/outflow_list.html b/application/outflows/templates/outflow_list.html similarity index 100% rename from outflows/templates/outflow_list.html rename to application/outflows/templates/outflow_list.html diff --git a/outflows/urls.py b/application/outflows/urls.py similarity index 100% rename from outflows/urls.py rename to application/outflows/urls.py diff --git a/outflows/views.py b/application/outflows/views.py similarity index 100% rename from outflows/views.py rename to application/outflows/views.py diff --git a/products/__init__.py b/application/products/__init__.py similarity index 100% rename from products/__init__.py rename to application/products/__init__.py diff --git a/products/admin.py b/application/products/admin.py similarity index 100% rename from products/admin.py rename to application/products/admin.py diff --git a/products/apps.py b/application/products/apps.py similarity index 100% rename from products/apps.py rename to application/products/apps.py diff --git a/products/forms.py b/application/products/forms.py similarity index 100% rename from products/forms.py rename to application/products/forms.py diff --git a/products/management/__init__.py b/application/products/management/__init__.py similarity index 100% rename from products/management/__init__.py rename to application/products/management/__init__.py diff --git a/products/management/commands/__init__.py b/application/products/management/commands/__init__.py similarity index 100% rename from products/management/commands/__init__.py rename to application/products/management/commands/__init__.py diff --git a/products/management/commands/fazer_coisas.py b/application/products/management/commands/fazer_coisas.py similarity index 100% rename from products/management/commands/fazer_coisas.py rename to application/products/management/commands/fazer_coisas.py diff --git a/products/migrations/0001_initial.py b/application/products/migrations/0001_initial.py similarity index 100% rename from products/migrations/0001_initial.py rename to application/products/migrations/0001_initial.py diff --git a/products/migrations/__init__.py b/application/products/migrations/__init__.py similarity index 100% rename from products/migrations/__init__.py rename to application/products/migrations/__init__.py diff --git a/products/models.py b/application/products/models.py similarity index 100% rename from products/models.py rename to application/products/models.py diff --git a/products/serializers.py b/application/products/serializers.py similarity index 100% rename from products/serializers.py rename to application/products/serializers.py diff --git a/products/templates/product_create.html b/application/products/templates/product_create.html similarity index 100% rename from products/templates/product_create.html rename to application/products/templates/product_create.html diff --git a/products/templates/product_delete.html b/application/products/templates/product_delete.html similarity index 100% rename from products/templates/product_delete.html rename to application/products/templates/product_delete.html diff --git a/products/templates/product_detail.html b/application/products/templates/product_detail.html similarity index 100% rename from products/templates/product_detail.html rename to application/products/templates/product_detail.html diff --git a/products/templates/product_list.html b/application/products/templates/product_list.html similarity index 100% rename from products/templates/product_list.html rename to application/products/templates/product_list.html diff --git a/products/templates/product_update.html b/application/products/templates/product_update.html similarity index 100% rename from products/templates/product_update.html rename to application/products/templates/product_update.html diff --git a/products/urls.py b/application/products/urls.py similarity index 100% rename from products/urls.py rename to application/products/urls.py diff --git a/products/views.py b/application/products/views.py similarity index 100% rename from products/views.py rename to application/products/views.py diff --git a/requirements.txt b/application/requirements.txt similarity index 100% rename from requirements.txt rename to application/requirements.txt diff --git a/requirements_dev.txt b/application/requirements_dev.txt similarity index 100% rename from requirements_dev.txt rename to application/requirements_dev.txt diff --git a/suppliers/__init__.py b/application/suppliers/__init__.py similarity index 100% rename from suppliers/__init__.py rename to application/suppliers/__init__.py diff --git a/suppliers/admin.py b/application/suppliers/admin.py similarity index 100% rename from suppliers/admin.py rename to application/suppliers/admin.py diff --git a/suppliers/apps.py b/application/suppliers/apps.py similarity index 100% rename from suppliers/apps.py rename to application/suppliers/apps.py diff --git a/suppliers/forms.py b/application/suppliers/forms.py similarity index 100% rename from suppliers/forms.py rename to application/suppliers/forms.py diff --git a/suppliers/migrations/0001_initial.py b/application/suppliers/migrations/0001_initial.py similarity index 100% rename from suppliers/migrations/0001_initial.py rename to application/suppliers/migrations/0001_initial.py diff --git a/suppliers/migrations/__init__.py b/application/suppliers/migrations/__init__.py similarity index 100% rename from suppliers/migrations/__init__.py rename to application/suppliers/migrations/__init__.py diff --git a/suppliers/models.py b/application/suppliers/models.py similarity index 100% rename from suppliers/models.py rename to application/suppliers/models.py diff --git a/suppliers/serializers.py b/application/suppliers/serializers.py similarity index 100% rename from suppliers/serializers.py rename to application/suppliers/serializers.py diff --git a/suppliers/templates/supplier_create.html b/application/suppliers/templates/supplier_create.html similarity index 100% rename from suppliers/templates/supplier_create.html rename to application/suppliers/templates/supplier_create.html diff --git a/suppliers/templates/supplier_delete.html b/application/suppliers/templates/supplier_delete.html similarity index 100% rename from suppliers/templates/supplier_delete.html rename to application/suppliers/templates/supplier_delete.html diff --git a/suppliers/templates/supplier_detail.html b/application/suppliers/templates/supplier_detail.html similarity index 100% rename from suppliers/templates/supplier_detail.html rename to application/suppliers/templates/supplier_detail.html diff --git a/suppliers/templates/supplier_list.html b/application/suppliers/templates/supplier_list.html similarity index 100% rename from suppliers/templates/supplier_list.html rename to application/suppliers/templates/supplier_list.html diff --git a/suppliers/templates/supplier_update.html b/application/suppliers/templates/supplier_update.html similarity index 100% rename from suppliers/templates/supplier_update.html rename to application/suppliers/templates/supplier_update.html diff --git a/suppliers/urls.py b/application/suppliers/urls.py similarity index 100% rename from suppliers/urls.py rename to application/suppliers/urls.py diff --git a/suppliers/views.py b/application/suppliers/views.py similarity index 100% rename from suppliers/views.py rename to application/suppliers/views.py diff --git a/docker-compose.yml b/docker-compose.yml index 0fcfd1ad..191603ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,9 @@ services: sge_web: build: . env_file: - - .env + - ./application/.env + volumes: + - ./application:/sge:rw restart: always ports: - 8000:8000 From 845c18fa890196a9166d406049b26026ba658771 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 07:42:26 -0300 Subject: [PATCH 02/12] Criado layout clientes --- application/app/settings.py | 1 + application/app/templates/components/_sidebar.html | 8 ++++++++ application/app/urls.py | 1 + 3 files changed, 10 insertions(+) diff --git a/application/app/settings.py b/application/app/settings.py index 4f61d79b..4919c6da 100644 --- a/application/app/settings.py +++ b/application/app/settings.py @@ -54,6 +54,7 @@ 'inflows', 'outflows', 'ai', + 'costumers', ] LOGIN_URL = 'login' diff --git a/application/app/templates/components/_sidebar.html b/application/app/templates/components/_sidebar.html index f81e145c..07e4b76d 100644 --- a/application/app/templates/components/_sidebar.html +++ b/application/app/templates/components/_sidebar.html @@ -21,6 +21,14 @@ {% endif %} + {% if perms.costumers.view_costumer %} +
  • + + + Clientes + +
  • + {% endif %} {% if perms.brands.view_brand %}
  • diff --git a/application/app/urls.py b/application/app/urls.py index 40fd1019..24bb047c 100644 --- a/application/app/urls.py +++ b/application/app/urls.py @@ -14,6 +14,7 @@ path('', views.home, name='home'), path('', include('suppliers.urls')), + path('', include('costumers.urls')), path('', include('brands.urls')), path('', include('categories.urls')), path('', include('products.urls')), From 66b76bdc13604bf81203c04e38157446b6d4be48 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 07:43:02 -0300 Subject: [PATCH 03/12] Novo Layout criado - costumers --- application/costumers/__init__.py | 0 application/costumers/admin.py | 10 +++ application/costumers/apps.py | 6 ++ application/costumers/forms.py | 17 +++++ .../costumers/migrations/0001_initial.py | 27 +++++++ application/costumers/migrations/__init__.py | 0 application/costumers/models.py | 14 ++++ application/costumers/serializers.py | 9 +++ .../costumers/templates/costumer_create.html | 18 +++++ .../costumers/templates/costumer_delete.html | 20 +++++ .../costumers/templates/costumer_detail.html | 16 ++++ .../costumers/templates/costumer_list.html | 74 +++++++++++++++++++ .../costumers/templates/costumer_update.html | 19 +++++ application/costumers/urls.py | 14 ++++ application/costumers/views.py | 61 +++++++++++++++ 15 files changed, 305 insertions(+) create mode 100644 application/costumers/__init__.py create mode 100644 application/costumers/admin.py create mode 100644 application/costumers/apps.py create mode 100644 application/costumers/forms.py create mode 100644 application/costumers/migrations/0001_initial.py create mode 100644 application/costumers/migrations/__init__.py create mode 100644 application/costumers/models.py create mode 100644 application/costumers/serializers.py create mode 100644 application/costumers/templates/costumer_create.html create mode 100644 application/costumers/templates/costumer_delete.html create mode 100644 application/costumers/templates/costumer_detail.html create mode 100644 application/costumers/templates/costumer_list.html create mode 100644 application/costumers/templates/costumer_update.html create mode 100644 application/costumers/urls.py create mode 100644 application/costumers/views.py diff --git a/application/costumers/__init__.py b/application/costumers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/application/costumers/admin.py b/application/costumers/admin.py new file mode 100644 index 00000000..617ef587 --- /dev/null +++ b/application/costumers/admin.py @@ -0,0 +1,10 @@ +from django.contrib import admin +from . import models + + +class SupplierAdmin(admin.ModelAdmin): + list_display = ('name', 'description',) + search_fields = ('name',) + + +admin.site.register(models.Supplier, SupplierAdmin) diff --git a/application/costumers/apps.py b/application/costumers/apps.py new file mode 100644 index 00000000..7c9a1180 --- /dev/null +++ b/application/costumers/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SuppliersConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'costumers' diff --git a/application/costumers/forms.py b/application/costumers/forms.py new file mode 100644 index 00000000..ddae4828 --- /dev/null +++ b/application/costumers/forms.py @@ -0,0 +1,17 @@ +from django import forms +from . import models + + +class SupplierForm(forms.ModelForm): + + class Meta: + model = models.Supplier + fields = ['name', 'description'] + widgets = { + 'name': forms.TextInput(attrs={'class': 'form-control'}), + 'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}), + } + labels = { + 'name': 'Nome', + 'description': 'Descrição', + } diff --git a/application/costumers/migrations/0001_initial.py b/application/costumers/migrations/0001_initial.py new file mode 100644 index 00000000..e3d67c84 --- /dev/null +++ b/application/costumers/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.1 on 2024-02-09 21:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Supplier', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=500)), + ('description', models.TextField(blank=True, null=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + options={ + 'ordering': ['name'], + }, + ), + ] diff --git a/application/costumers/migrations/__init__.py b/application/costumers/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/application/costumers/models.py b/application/costumers/models.py new file mode 100644 index 00000000..8c13172b --- /dev/null +++ b/application/costumers/models.py @@ -0,0 +1,14 @@ +from django.db import models + + +class Supplier(models.Model): + name = models.CharField(max_length=500) + description = models.TextField(null=True, blank=True) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + + class Meta: + ordering = ['name'] + + def __str__(self): + return self.name diff --git a/application/costumers/serializers.py b/application/costumers/serializers.py new file mode 100644 index 00000000..0376802b --- /dev/null +++ b/application/costumers/serializers.py @@ -0,0 +1,9 @@ +from rest_framework import serializers +from costumers.models import Supplier + + +class SupplierSerializer(serializers.ModelSerializer): + + class Meta: + model = Supplier + fields = '__all__' diff --git a/application/costumers/templates/costumer_create.html b/application/costumers/templates/costumer_create.html new file mode 100644 index 00000000..8ed50573 --- /dev/null +++ b/application/costumers/templates/costumer_create.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} + +{% block content %} + +{% endblock %} diff --git a/application/costumers/templates/costumer_delete.html b/application/costumers/templates/costumer_delete.html new file mode 100644 index 00000000..cf41361f --- /dev/null +++ b/application/costumers/templates/costumer_delete.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% block content %} +
    +

    Deletar Fornecedor

    + +
    +
    +

    Tem certeza de que deseja excluir o fornecedor {{ object.name }}?

    + +
    + {% csrf_token %} + +
    + + Cancelar e Voltar para a Lista de Fornecedores +
    +
    +
    +{% endblock %} diff --git a/application/costumers/templates/costumer_detail.html b/application/costumers/templates/costumer_detail.html new file mode 100644 index 00000000..aa8e3803 --- /dev/null +++ b/application/costumers/templates/costumer_detail.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} + +{% block content %} +
    +

    Detalhes do Fornecedor

    + +
    +
    +

    {{ object.name }}

    +

    {{ object.description }}

    +
    +
    + + Voltar para a Lista de Fornecedores +
    +{% endblock %} diff --git a/application/costumers/templates/costumer_list.html b/application/costumers/templates/costumer_list.html new file mode 100644 index 00000000..9a23bbd9 --- /dev/null +++ b/application/costumers/templates/costumer_list.html @@ -0,0 +1,74 @@ +{% extends 'base.html' %} + +{% block title %} +SGE - Fornecedores +{% endblock %} + +{% block content %} + +
    +
    +
    +
    + + +
    +
    +
    + {% if perms.costumers.add_costumer %} + + {% endif %} +
    + +
    + + + + + + + + + + + {% for costumer in costumers %} + + + + + + + {% endfor %} + +
    IDNomeDescriçãoAções
    + + {{ costumer.id }} + + {{ costumer.name }}{{ costumer.description }} + + + + + {% if perms.costumers.change_costumer %} + + + + {% endif %} + + {% if perms.costumers.delete_costumer %} + + + + {% endif %} +
    +
    + +{% include 'components/_pagination.html' %} + +{% endblock %} \ No newline at end of file diff --git a/application/costumers/templates/costumer_update.html b/application/costumers/templates/costumer_update.html new file mode 100644 index 00000000..b5c9f309 --- /dev/null +++ b/application/costumers/templates/costumer_update.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} + +{% block content %} +
    +

    Editar Fornecedor

    + +
    +
    +
    + {% csrf_token %} + {{ form.as_p }} + +
    +
    +
    + + Cancelar e Voltar para a Lista de Fornecedores +
    +{% endblock %} diff --git a/application/costumers/urls.py b/application/costumers/urls.py new file mode 100644 index 00000000..5bd013d5 --- /dev/null +++ b/application/costumers/urls.py @@ -0,0 +1,14 @@ +from django.urls import path +from . import views + + +urlpatterns = [ + path('costumers/list/', views.SupplierListView.as_view(), name='costumer_list'), + path('costumers/create/', views.SupplierCreateView.as_view(), name='costumer_create'), + path('costumers//detail/', views.SupplierDetailView.as_view(), name='costumer_detail'), + path('costumers//update/', views.SupplierUpdateView.as_view(), name='costumer_update'), + path('costumers//delete/', views.SupplierDeleteView.as_view(), name='costumer_delete'), + + path('api/v1/costumers/', views.SupplierCreateListAPIView.as_view(), name='costumer-create-list-api-view'), + path('api/v1/costumers//', views.SupplierRetrieveUpdateDestroyAPIView.as_view(), name='costumer-detail-api-view'), +] diff --git a/application/costumers/views.py b/application/costumers/views.py new file mode 100644 index 00000000..b01eb40f --- /dev/null +++ b/application/costumers/views.py @@ -0,0 +1,61 @@ +from rest_framework import generics +from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin +from django.urls import reverse_lazy +from django.views.generic import ListView, CreateView, DetailView, UpdateView, DeleteView +from . import models, forms, serializers + + +class SupplierListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): + model = models.Supplier + template_name = 'costumer_list.html' + context_object_name = 'costumers' + paginate_by = 10 + permission_required = 'costumers.view_costumer' + + def get_queryset(self): + queryset = super().get_queryset() + name = self.request.GET.get('name') + + if name: + queryset = queryset.filter(name__icontains=name) + + return queryset + + +class SupplierCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView): + model = models.Supplier + template_name = 'costumer_create.html' + form_class = forms.SupplierForm + success_url = reverse_lazy('costumer_list') + permission_required = 'costumers.add_costumer' + + +class SupplierDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView): + model = models.Supplier + template_name = 'costumer_detail.html' + permission_required = 'costumers.view_costumer' + + +class SupplierUpdateView(LoginRequiredMixin, PermissionRequiredMixin, UpdateView): + model = models.Supplier + template_name = 'costumer_update.html' + form_class = forms.SupplierForm + success_url = reverse_lazy('costumer_list') + permission_required = 'costumers.change_costumer' + + +class SupplierDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteView): + model = models.Supplier + template_name = 'costumer_delete.html' + success_url = reverse_lazy('costumer_list') + permission_required = 'costumers.delete_costumer' + + +class SupplierCreateListAPIView(generics.ListCreateAPIView): + queryset = models.Supplier.objects.all() + serializer_class = serializers.SupplierSerializer + + +class SupplierRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): + queryset = models.Supplier.objects.all() + serializer_class = serializers.SupplierSerializer From a6735bab21184f682dd8cd37a388b9769acd4453 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 10:30:57 -0300 Subject: [PATCH 04/12] Cadastro Cliente finalizado --- application/costumers/admin.py | 6 ++-- application/costumers/apps.py | 2 +- application/costumers/forms.py | 22 +++++++++--- .../costumers/migrations/0001_initial.py | 15 +++++--- application/costumers/models.py | 13 +++++-- application/costumers/serializers.py | 6 ++-- .../costumers/templates/costumer_create.html | 6 ++-- .../costumers/templates/costumer_delete.html | 4 +-- .../costumers/templates/costumer_detail.html | 12 +++++-- .../costumers/templates/costumer_list.html | 21 ++++++++--- .../costumers/templates/costumer_update.html | 6 ++-- application/costumers/urls.py | 14 ++++---- application/costumers/views.py | 36 +++++++++---------- 13 files changed, 103 insertions(+), 60 deletions(-) diff --git a/application/costumers/admin.py b/application/costumers/admin.py index 617ef587..5509adce 100644 --- a/application/costumers/admin.py +++ b/application/costumers/admin.py @@ -2,9 +2,9 @@ from . import models -class SupplierAdmin(admin.ModelAdmin): - list_display = ('name', 'description',) +class CostumerAdmin(admin.ModelAdmin): + list_display = ('name', 'mail', 'phone', 'document_id', 'address', 'city' , 'state' , 'zip_code') search_fields = ('name',) -admin.site.register(models.Supplier, SupplierAdmin) +admin.site.register(models.Costumer, CostumerAdmin) diff --git a/application/costumers/apps.py b/application/costumers/apps.py index 7c9a1180..cc1b8f20 100644 --- a/application/costumers/apps.py +++ b/application/costumers/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -class SuppliersConfig(AppConfig): +class CostumersConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'costumers' diff --git a/application/costumers/forms.py b/application/costumers/forms.py index ddae4828..7732a5fc 100644 --- a/application/costumers/forms.py +++ b/application/costumers/forms.py @@ -2,16 +2,28 @@ from . import models -class SupplierForm(forms.ModelForm): +class CostumerForm(forms.ModelForm): class Meta: - model = models.Supplier - fields = ['name', 'description'] + model = models.Costumer + fields = ['name', 'mail', 'phone', 'document_id', 'address', 'city' , 'state' , 'zip_code'] widgets = { 'name': forms.TextInput(attrs={'class': 'form-control'}), - 'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}), + 'mail': forms.TextInput(attrs={'class': 'form-control'}), + 'phone': forms.TextInput(attrs={'class': 'form-control'}), + 'document_id': forms.TextInput(attrs={'class': 'form-control'}), + 'address': forms.TextInput(attrs={'class': 'form-control'}), + 'city': forms.TextInput(attrs={'class': 'form-control'}), + 'state': forms.TextInput(attrs={'class': 'form-control', 'maxlength': '2'}), + 'zip_code': forms.TextInput(attrs={'class': 'form-control'}), } labels = { 'name': 'Nome', - 'description': 'Descrição', + 'mail': 'E-mail', + 'phone': 'Telefone', + 'document_id': 'CPF/CNPJ', + 'address': 'Endereço', + 'city': 'Cidade', + 'state': 'Estado', + 'zip_code': 'CEP', } diff --git a/application/costumers/migrations/0001_initial.py b/application/costumers/migrations/0001_initial.py index e3d67c84..336d80a9 100644 --- a/application/costumers/migrations/0001_initial.py +++ b/application/costumers/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.1 on 2024-02-09 21:42 +# Generated by Django 5.0.1 on 2025-11-08 13:29 from django.db import migrations, models @@ -12,11 +12,18 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Supplier', + name='Costumer', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=500)), - ('description', models.TextField(blank=True, null=True)), + ('name', models.CharField(max_length=50)), + ('mail', models.TextField(blank=True, null=True)), + ('phone', models.CharField(blank=True, max_length=15)), + ('document_id', models.CharField(blank=True, max_length=15)), + ('address', models.CharField(blank=True, max_length=300)), + ('city', models.CharField(blank=True, max_length=100)), + ('state', models.CharField(blank=True, max_length=2)), + ('zip_code', models.CharField(blank=True, max_length=10)), + ('active', models.BooleanField(default=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ], diff --git a/application/costumers/models.py b/application/costumers/models.py index 8c13172b..c285fb1d 100644 --- a/application/costumers/models.py +++ b/application/costumers/models.py @@ -1,9 +1,16 @@ from django.db import models -class Supplier(models.Model): - name = models.CharField(max_length=500) - description = models.TextField(null=True, blank=True) +class Costumer(models.Model): + name = models.CharField(max_length=50) + mail = models.TextField(null=True, blank=True) + phone = models.CharField(max_length=15, blank=True) + document_id = models.CharField(max_length=15, blank=True) + address = models.CharField(max_length=300, blank=True) + city = models.CharField(max_length=100, blank=True) + state = models.CharField(max_length=2, blank=True) + zip_code = models.CharField(max_length=10, blank=True) + active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) diff --git a/application/costumers/serializers.py b/application/costumers/serializers.py index 0376802b..f778ddc6 100644 --- a/application/costumers/serializers.py +++ b/application/costumers/serializers.py @@ -1,9 +1,9 @@ from rest_framework import serializers -from costumers.models import Supplier +from costumers.models import Costumer -class SupplierSerializer(serializers.ModelSerializer): +class CostumerSerializer(serializers.ModelSerializer): class Meta: - model = Supplier + model = Costumer fields = '__all__' diff --git a/application/costumers/templates/costumer_create.html b/application/costumers/templates/costumer_create.html index 8ed50573..2b9c38b5 100644 --- a/application/costumers/templates/costumer_create.html +++ b/application/costumers/templates/costumer_create.html @@ -2,17 +2,17 @@ {% block content %}
    -

    Cadastrar Fornecedor

    +

    Cadastrar Cliente

    {% csrf_token %} {{ form.as_p }} - +
    - Cancelar e Voltar para a Lista de Fornecedores + Cancelar e Voltar para a Lista de Clientes
    {% endblock %} diff --git a/application/costumers/templates/costumer_delete.html b/application/costumers/templates/costumer_delete.html index cf41361f..621ede1c 100644 --- a/application/costumers/templates/costumer_delete.html +++ b/application/costumers/templates/costumer_delete.html @@ -2,7 +2,7 @@ {% block content %}
    -

    Deletar Fornecedor

    +

    Deletar Cliente

    diff --git a/application/costumers/templates/costumer_detail.html b/application/costumers/templates/costumer_detail.html index aa8e3803..b51f1521 100644 --- a/application/costumers/templates/costumer_detail.html +++ b/application/costumers/templates/costumer_detail.html @@ -2,15 +2,21 @@ {% block content %}
    -

    Detalhes do Fornecedor

    +

    Detalhes do Cliente

    {{ object.name }}

    -

    {{ object.description }}

    +

    {{ object.mail }}

    +

    {{ object.phone }}

    +

    {{ object.document_id }}

    +

    {{ object.address }}

    +

    {{ object.city }}

    +

    {{ object.state }}

    +

    {{ object.zip_code }}

    - Voltar para a Lista de Fornecedores + Voltar para a Lista de Clientes
    {% endblock %} diff --git a/application/costumers/templates/costumer_list.html b/application/costumers/templates/costumer_list.html index 9a23bbd9..ccd24bdd 100644 --- a/application/costumers/templates/costumer_list.html +++ b/application/costumers/templates/costumer_list.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block title %} -SGE - Fornecedores +SGE - Clientes {% endblock %} {% block content %} @@ -20,7 +20,7 @@ {% if perms.costumers.add_costumer %} {% endif %} @@ -32,8 +32,13 @@ ID Nome - Descrição - Ações + E-mail + Telefone + CPF/CNPJ + Endereço + Cidade + Estado + CEP @@ -45,7 +50,13 @@ {{ costumer.name }} - {{ costumer.description }} + {{ costumer.mail }} + {{ costumer.phone }} + {{ costumer.document_id }} + {{ costumer.address }} + {{ costumer.city }} + {{ costumer.state }} + {{ costumer.zip_code }} diff --git a/application/costumers/templates/costumer_update.html b/application/costumers/templates/costumer_update.html index b5c9f309..675d71c3 100644 --- a/application/costumers/templates/costumer_update.html +++ b/application/costumers/templates/costumer_update.html @@ -2,18 +2,18 @@ {% block content %} {% endblock %} diff --git a/application/costumers/urls.py b/application/costumers/urls.py index 5bd013d5..218f4e8d 100644 --- a/application/costumers/urls.py +++ b/application/costumers/urls.py @@ -3,12 +3,12 @@ urlpatterns = [ - path('costumers/list/', views.SupplierListView.as_view(), name='costumer_list'), - path('costumers/create/', views.SupplierCreateView.as_view(), name='costumer_create'), - path('costumers//detail/', views.SupplierDetailView.as_view(), name='costumer_detail'), - path('costumers//update/', views.SupplierUpdateView.as_view(), name='costumer_update'), - path('costumers//delete/', views.SupplierDeleteView.as_view(), name='costumer_delete'), + path('costumers/list/', views.CostumerListView.as_view(), name='costumer_list'), + path('costumers/create/', views.CostumerCreateView.as_view(), name='costumer_create'), + path('costumers//detail/', views.CostumerDetailView.as_view(), name='costumer_detail'), + path('costumers//update/', views.CostumerUpdateView.as_view(), name='costumer_update'), + path('costumers//delete/', views.CostumerDeleteView.as_view(), name='costumer_delete'), - path('api/v1/costumers/', views.SupplierCreateListAPIView.as_view(), name='costumer-create-list-api-view'), - path('api/v1/costumers//', views.SupplierRetrieveUpdateDestroyAPIView.as_view(), name='costumer-detail-api-view'), + path('api/v1/costumers/', views.CostumerCreateListAPIView.as_view(), name='costumer-create-list-api-view'), + path('api/v1/costumers//', views.CostumerRetrieveUpdateDestroyAPIView.as_view(), name='costumer-detail-api-view'), ] diff --git a/application/costumers/views.py b/application/costumers/views.py index b01eb40f..e1a811c6 100644 --- a/application/costumers/views.py +++ b/application/costumers/views.py @@ -5,8 +5,8 @@ from . import models, forms, serializers -class SupplierListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): - model = models.Supplier +class CostumerListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): + model = models.Costumer template_name = 'costumer_list.html' context_object_name = 'costumers' paginate_by = 10 @@ -22,40 +22,40 @@ def get_queryset(self): return queryset -class SupplierCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView): - model = models.Supplier +class CostumerCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView): + model = models.Costumer template_name = 'costumer_create.html' - form_class = forms.SupplierForm + form_class = forms.CostumerForm success_url = reverse_lazy('costumer_list') permission_required = 'costumers.add_costumer' -class SupplierDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView): - model = models.Supplier +class CostumerDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView): + model = models.Costumer template_name = 'costumer_detail.html' permission_required = 'costumers.view_costumer' -class SupplierUpdateView(LoginRequiredMixin, PermissionRequiredMixin, UpdateView): - model = models.Supplier +class CostumerUpdateView(LoginRequiredMixin, PermissionRequiredMixin, UpdateView): + model = models.Costumer template_name = 'costumer_update.html' - form_class = forms.SupplierForm + form_class = forms.CostumerForm success_url = reverse_lazy('costumer_list') permission_required = 'costumers.change_costumer' -class SupplierDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteView): - model = models.Supplier +class CostumerDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteView): + model = models.Costumer template_name = 'costumer_delete.html' success_url = reverse_lazy('costumer_list') permission_required = 'costumers.delete_costumer' -class SupplierCreateListAPIView(generics.ListCreateAPIView): - queryset = models.Supplier.objects.all() - serializer_class = serializers.SupplierSerializer +class CostumerCreateListAPIView(generics.ListCreateAPIView): + queryset = models.Costumer.objects.all() + serializer_class = serializers.CostumerSerializer -class SupplierRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): - queryset = models.Supplier.objects.all() - serializer_class = serializers.SupplierSerializer +class CostumerRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): + queryset = models.Costumer.objects.all() + serializer_class = serializers.CostumerSerializer From fc52ff61cede719e91c526901851cdf35f3a6903 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 11:20:57 -0300 Subject: [PATCH 05/12] Exportar Clientes - OK --- application/costumers/templates/costumer_list.html | 1 + application/costumers/urls.py | 1 + application/costumers/views.py | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/application/costumers/templates/costumer_list.html b/application/costumers/templates/costumer_list.html index ccd24bdd..1f0d811d 100644 --- a/application/costumers/templates/costumer_list.html +++ b/application/costumers/templates/costumer_list.html @@ -21,6 +21,7 @@ {% endif %} diff --git a/application/costumers/urls.py b/application/costumers/urls.py index 218f4e8d..4a02459a 100644 --- a/application/costumers/urls.py +++ b/application/costumers/urls.py @@ -8,6 +8,7 @@ path('costumers//detail/', views.CostumerDetailView.as_view(), name='costumer_detail'), path('costumers//update/', views.CostumerUpdateView.as_view(), name='costumer_update'), path('costumers//delete/', views.CostumerDeleteView.as_view(), name='costumer_delete'), + path("costumers/export/", views.costumers_export, name="costumers_export"), path('api/v1/costumers/', views.CostumerCreateListAPIView.as_view(), name='costumer-create-list-api-view'), path('api/v1/costumers//', views.CostumerRetrieveUpdateDestroyAPIView.as_view(), name='costumer-detail-api-view'), diff --git a/application/costumers/views.py b/application/costumers/views.py index e1a811c6..41dd6b4f 100644 --- a/application/costumers/views.py +++ b/application/costumers/views.py @@ -3,6 +3,8 @@ from django.urls import reverse_lazy from django.views.generic import ListView, CreateView, DetailView, UpdateView, DeleteView from . import models, forms, serializers +from django.http import HttpResponse +import csv class CostumerListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): @@ -59,3 +61,14 @@ class CostumerCreateListAPIView(generics.ListCreateAPIView): class CostumerRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): queryset = models.Costumer.objects.all() serializer_class = serializers.CostumerSerializer + +def costumers_export(request): + response = HttpResponse(content_type="text/csv") + response["Content-Disposition"] = 'attachment; filename="clientes.csv"' + writer = csv.writer(response) + writer.writerow(["Nome", "E-mail", "Telefone", "CPF/CNPJ", "Endereço", "Cidade", "Estado", "CEP", "Data de Criação"]) + + for c in models.Costumer.objects.all(): + writer.writerow([c.name, c.mail, c.phone, c.document_id, c.address, c.city, c.state, c.zip_code, c.created_at]) + + return response From 1c56f1cc4ec9631a39f502aae60774ef1ddb5c53 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 11:32:32 -0300 Subject: [PATCH 06/12] Exportar Produtos CSV - OK --- application/products/templates/product_list.html | 1 + application/products/urls.py | 1 + application/products/views.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/application/products/templates/product_list.html b/application/products/templates/product_list.html index 0d870646..30cfde30 100644 --- a/application/products/templates/product_list.html +++ b/application/products/templates/product_list.html @@ -28,6 +28,7 @@ {% endif %} diff --git a/application/products/urls.py b/application/products/urls.py index c51c916c..8a98bc47 100644 --- a/application/products/urls.py +++ b/application/products/urls.py @@ -8,6 +8,7 @@ path('products//detail/', views.ProductDetailView.as_view(), name='product_detail'), path('products//update/', views.ProductUpdateView.as_view(), name='product_update'), path('products//delete/', views.ProductDeleteView.as_view(), name='product_delete'), + path("products/export/", views.products_export, name="products_export"), path('api/v1/products/', views.ProductCreateListAPIView.as_view(), name='product-create-list-api-view'), path('api/v1/products//', views.ProductRetrieveUpdateDestroyAPIView.as_view(), name='product-detail-api-view'), diff --git a/application/products/views.py b/application/products/views.py index 66e0cb73..30ceada3 100644 --- a/application/products/views.py +++ b/application/products/views.py @@ -6,6 +6,9 @@ from brands.models import Brand from categories.models import Category from . import models, forms, serializers +from django.http import HttpResponse +import csv + class ProductListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): @@ -79,3 +82,15 @@ class ProductCreateListAPIView(generics.ListCreateAPIView): class ProductRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): queryset = models.Product.objects.all() serializer_class = serializers.ProductSerializer + +def products_export(request): + response = HttpResponse(content_type="text/csv") + response["Content-Disposition"] = 'attachment; filename="clientes.csv"' + writer = csv.writer(response) + writer.writerow(["Título", "Categoria", "Marca", "Descrição", "Número de Série", "Preço de Custo", "Preço de Venda"]) + + for c in models.Product.objects.all(): + writer.writerow([c.title, c.category, c.brand, c.description, c.serie_number, c.cost_price, c.selling_price]) + + return response + From 4847eb74e2c9266536b27d8723e2d3c7f42d6db6 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 11:38:16 -0300 Subject: [PATCH 07/12] Exportar Fornecedor CSV - OK --- application/suppliers/templates/supplier_list.html | 2 ++ application/suppliers/urls.py | 1 + application/suppliers/views.py | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/application/suppliers/templates/supplier_list.html b/application/suppliers/templates/supplier_list.html index f6c3f1d9..4134a72d 100644 --- a/application/suppliers/templates/supplier_list.html +++ b/application/suppliers/templates/supplier_list.html @@ -21,6 +21,8 @@ {% endif %} diff --git a/application/suppliers/urls.py b/application/suppliers/urls.py index 652a93ae..350ca652 100644 --- a/application/suppliers/urls.py +++ b/application/suppliers/urls.py @@ -8,6 +8,7 @@ path('suppliers//detail/', views.SupplierDetailView.as_view(), name='supplier_detail'), path('suppliers//update/', views.SupplierUpdateView.as_view(), name='supplier_update'), path('suppliers//delete/', views.SupplierDeleteView.as_view(), name='supplier_delete'), + path("suppliers/export/", views.suppliers_export, name="suppliers_export"), path('api/v1/suppliers/', views.SupplierCreateListAPIView.as_view(), name='supplier-create-list-api-view'), path('api/v1/suppliers//', views.SupplierRetrieveUpdateDestroyAPIView.as_view(), name='supplier-detail-api-view'), diff --git a/application/suppliers/views.py b/application/suppliers/views.py index 48bf7c8d..56a9978d 100644 --- a/application/suppliers/views.py +++ b/application/suppliers/views.py @@ -3,6 +3,8 @@ from django.urls import reverse_lazy from django.views.generic import ListView, CreateView, DetailView, UpdateView, DeleteView from . import models, forms, serializers +from django.http import HttpResponse +import csv class SupplierListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): @@ -59,3 +61,14 @@ class SupplierCreateListAPIView(generics.ListCreateAPIView): class SupplierRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): queryset = models.Supplier.objects.all() serializer_class = serializers.SupplierSerializer + +def suppliers_export(request): + response = HttpResponse(content_type="text/csv") + response["Content-Disposition"] = 'attachment; filename="clientes.csv"' + writer = csv.writer(response) + writer.writerow(["Nome", "Descrição"]) + + for c in models.Supplier.objects.all(): + writer.writerow([c.name, c.description, c.phone, c.document_id, c.address, c.city, c.state, c.zip_code, c.created_at]) + + return response From 4e20c51ec0c0e0e4705698033866efd52f58f2f2 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 12:21:58 -0300 Subject: [PATCH 08/12] Update dados Fornecedor --- application/suppliers/admin.py | 2 +- application/suppliers/forms.py | 24 ++++++- ...supplier_city_supplier_contact_and_more.py | 68 +++++++++++++++++++ application/suppliers/models.py | 12 +++- .../suppliers/templates/supplier_list.html | 9 ++- 5 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 application/suppliers/migrations/0002_supplier_address_supplier_city_supplier_contact_and_more.py diff --git a/application/suppliers/admin.py b/application/suppliers/admin.py index 617ef587..026be2a3 100644 --- a/application/suppliers/admin.py +++ b/application/suppliers/admin.py @@ -3,7 +3,7 @@ class SupplierAdmin(admin.ModelAdmin): - list_display = ('name', 'description',) + list_display = ('name', 'mail', 'phone', 'site', 'document_id', 'contact', 'contact_phone', 'address', 'city' , 'state' , 'zip_code', 'description') search_fields = ('name',) diff --git a/application/suppliers/forms.py b/application/suppliers/forms.py index ddae4828..13b387f8 100644 --- a/application/suppliers/forms.py +++ b/application/suppliers/forms.py @@ -6,12 +6,32 @@ class SupplierForm(forms.ModelForm): class Meta: model = models.Supplier - fields = ['name', 'description'] + fields = ['name', 'mail', 'phone', 'site', 'document_id', 'contact', 'contact_phone', 'address', 'city' , 'state' , 'zip_code', 'description'] widgets = { 'name': forms.TextInput(attrs={'class': 'form-control'}), + 'mail': forms.TextInput(attrs={'class': 'form-control'}), + 'phone': forms.TextInput(attrs={'class': 'form-control'}), + 'site': forms.TextInput(attrs={'class': 'form-control'}), + 'document_id': forms.TextInput(attrs={'class': 'form-control'}), + 'contact': forms.TextInput(attrs={'class': 'form-control'}), + 'contact_phone': forms.TextInput(attrs={'class': 'form-control'}), + 'address': forms.TextInput(attrs={'class': 'form-control'}), + 'city': forms.TextInput(attrs={'class': 'form-control'}), + 'state': forms.TextInput(attrs={'class': 'form-control', 'maxlength': '2'}), + 'zip_code': forms.TextInput(attrs={'class': 'form-control'}), 'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}), } labels = { - 'name': 'Nome', + 'name': 'Fornecedor', + 'mail': 'E-mail', + 'phone': 'Telefone', + 'site': 'Site/MediaSocial', + 'document_id': 'CPF/CNPJ', + 'contact': 'Representante/Vendedor', + 'contact_phone': 'Contato Representante/Vendedor', + 'address': 'Endereço', + 'city': 'Cidade', + 'state': 'Estado', + 'zip_code': 'CEP', 'description': 'Descrição', } diff --git a/application/suppliers/migrations/0002_supplier_address_supplier_city_supplier_contact_and_more.py b/application/suppliers/migrations/0002_supplier_address_supplier_city_supplier_contact_and_more.py new file mode 100644 index 00000000..665f8f17 --- /dev/null +++ b/application/suppliers/migrations/0002_supplier_address_supplier_city_supplier_contact_and_more.py @@ -0,0 +1,68 @@ +# Generated by Django 5.0.1 on 2025-11-08 15:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('suppliers', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='supplier', + name='address', + field=models.CharField(blank=True, max_length=300), + ), + migrations.AddField( + model_name='supplier', + name='city', + field=models.CharField(blank=True, max_length=30), + ), + migrations.AddField( + model_name='supplier', + name='contact', + field=models.CharField(blank=True, max_length=50), + ), + migrations.AddField( + model_name='supplier', + name='contact_phone', + field=models.CharField(blank=True, max_length=20), + ), + migrations.AddField( + model_name='supplier', + name='document_id', + field=models.CharField(blank=True, max_length=15), + ), + migrations.AddField( + model_name='supplier', + name='mail', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='supplier', + name='phone', + field=models.CharField(blank=True, max_length=15), + ), + migrations.AddField( + model_name='supplier', + name='site', + field=models.CharField(blank=True, max_length=50), + ), + migrations.AddField( + model_name='supplier', + name='state', + field=models.CharField(blank=True, max_length=2), + ), + migrations.AddField( + model_name='supplier', + name='zip_code', + field=models.CharField(blank=True, max_length=10), + ), + migrations.AlterField( + model_name='supplier', + name='name', + field=models.CharField(max_length=50), + ), + ] diff --git a/application/suppliers/models.py b/application/suppliers/models.py index 8c13172b..3f79d910 100644 --- a/application/suppliers/models.py +++ b/application/suppliers/models.py @@ -2,7 +2,17 @@ class Supplier(models.Model): - name = models.CharField(max_length=500) + name = models.CharField(max_length=50) + mail = models.TextField(null=True, blank=True) + phone = models.CharField(max_length=15, blank=True) + site = models.CharField(max_length=50, blank=True) + document_id = models.CharField(max_length=15, blank=True) + contact = models.CharField(max_length=50, blank=True) + contact_phone = models.CharField(max_length=20, blank=True) + address = models.CharField(max_length=300, blank=True) + city = models.CharField(max_length=30, blank=True) + state = models.CharField(max_length=2, blank=True) + zip_code = models.CharField(max_length=10, blank=True) description = models.TextField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) diff --git a/application/suppliers/templates/supplier_list.html b/application/suppliers/templates/supplier_list.html index 4134a72d..c28cf579 100644 --- a/application/suppliers/templates/supplier_list.html +++ b/application/suppliers/templates/supplier_list.html @@ -34,7 +34,14 @@ ID Nome - Descrição + E-mail + Telefone + Site/MediaSocial + CPF/CNPJ + Representante/Vendedor + Contato Representante/Vendedor + Cidade + Estado Ações From 56f926541c0de57409c1bc1aa68584b3bbca61cd Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 12:27:30 -0300 Subject: [PATCH 09/12] Adicioando MediaSocial ao cadastro do cliente --- application/costumers/admin.py | 2 +- application/costumers/forms.py | 4 +++- .../migrations/0002_costumer_social_media.py | 18 ++++++++++++++++++ application/costumers/models.py | 1 + .../costumers/templates/costumer_list.html | 1 + application/costumers/views.py | 4 ++-- 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 application/costumers/migrations/0002_costumer_social_media.py diff --git a/application/costumers/admin.py b/application/costumers/admin.py index 5509adce..8c70a9ad 100644 --- a/application/costumers/admin.py +++ b/application/costumers/admin.py @@ -3,7 +3,7 @@ class CostumerAdmin(admin.ModelAdmin): - list_display = ('name', 'mail', 'phone', 'document_id', 'address', 'city' , 'state' , 'zip_code') + list_display = ('name', 'mail', 'phone', 'document_id', 'social_media','address', 'city' , 'state' , 'zip_code') search_fields = ('name',) diff --git a/application/costumers/forms.py b/application/costumers/forms.py index 7732a5fc..8c289c2d 100644 --- a/application/costumers/forms.py +++ b/application/costumers/forms.py @@ -6,12 +6,13 @@ class CostumerForm(forms.ModelForm): class Meta: model = models.Costumer - fields = ['name', 'mail', 'phone', 'document_id', 'address', 'city' , 'state' , 'zip_code'] + fields = ['name', 'mail', 'phone', 'document_id', 'social_media', 'address', 'city' , 'state' , 'zip_code'] widgets = { 'name': forms.TextInput(attrs={'class': 'form-control'}), 'mail': forms.TextInput(attrs={'class': 'form-control'}), 'phone': forms.TextInput(attrs={'class': 'form-control'}), 'document_id': forms.TextInput(attrs={'class': 'form-control'}), + 'social_media': forms.TextInput(attrs={'class': 'form-control'}), 'address': forms.TextInput(attrs={'class': 'form-control'}), 'city': forms.TextInput(attrs={'class': 'form-control'}), 'state': forms.TextInput(attrs={'class': 'form-control', 'maxlength': '2'}), @@ -22,6 +23,7 @@ class Meta: 'mail': 'E-mail', 'phone': 'Telefone', 'document_id': 'CPF/CNPJ', + 'social_media': 'Site/MediaSocial', 'address': 'Endereço', 'city': 'Cidade', 'state': 'Estado', diff --git a/application/costumers/migrations/0002_costumer_social_media.py b/application/costumers/migrations/0002_costumer_social_media.py new file mode 100644 index 00000000..bfdf86f9 --- /dev/null +++ b/application/costumers/migrations/0002_costumer_social_media.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.1 on 2025-11-08 15:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('costumers', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='costumer', + name='social_media', + field=models.CharField(blank=True, max_length=15), + ), + ] diff --git a/application/costumers/models.py b/application/costumers/models.py index c285fb1d..a2d158e4 100644 --- a/application/costumers/models.py +++ b/application/costumers/models.py @@ -6,6 +6,7 @@ class Costumer(models.Model): mail = models.TextField(null=True, blank=True) phone = models.CharField(max_length=15, blank=True) document_id = models.CharField(max_length=15, blank=True) + social_media = models.CharField(max_length=100, blank=True) address = models.CharField(max_length=300, blank=True) city = models.CharField(max_length=100, blank=True) state = models.CharField(max_length=2, blank=True) diff --git a/application/costumers/templates/costumer_list.html b/application/costumers/templates/costumer_list.html index 1f0d811d..430dd0e7 100644 --- a/application/costumers/templates/costumer_list.html +++ b/application/costumers/templates/costumer_list.html @@ -35,6 +35,7 @@ Nome E-mail Telefone + Site/MediaSocial CPF/CNPJ Endereço Cidade diff --git a/application/costumers/views.py b/application/costumers/views.py index 41dd6b4f..ec8c060f 100644 --- a/application/costumers/views.py +++ b/application/costumers/views.py @@ -66,9 +66,9 @@ def costumers_export(request): response = HttpResponse(content_type="text/csv") response["Content-Disposition"] = 'attachment; filename="clientes.csv"' writer = csv.writer(response) - writer.writerow(["Nome", "E-mail", "Telefone", "CPF/CNPJ", "Endereço", "Cidade", "Estado", "CEP", "Data de Criação"]) + writer.writerow(["Nome", "E-mail", "Telefone", "Site/MediaSocial", "CPF/CNPJ", "Endereço", "Cidade", "Estado", "CEP", "Data de Criação"]) for c in models.Costumer.objects.all(): - writer.writerow([c.name, c.mail, c.phone, c.document_id, c.address, c.city, c.state, c.zip_code, c.created_at]) + writer.writerow([c.name, c.mail, c.phone, c.document_id, c.social_media, c.address, c.city, c.state, c.zip_code, c.created_at]) return response From 482b94dea791784dfe6257323774d1a2f9f14b07 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 13:04:54 -0300 Subject: [PATCH 10/12] Fornecedor OK --- .../0003_alter_costumer_social_media.py | 18 ++++++++++++ application/suppliers/forms.py | 6 ++-- ...address_alter_supplier_contact_and_more.py | 28 +++++++++++++++++++ ...lier_contact_alter_supplier_document_id.py | 23 +++++++++++++++ application/suppliers/models.py | 2 +- .../suppliers/templates/supplier_detail.html | 10 ++++++- .../suppliers/templates/supplier_list.html | 16 +++++++---- 7 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 application/costumers/migrations/0003_alter_costumer_social_media.py create mode 100644 application/suppliers/migrations/0003_alter_supplier_address_alter_supplier_contact_and_more.py create mode 100644 application/suppliers/migrations/0004_alter_supplier_contact_alter_supplier_document_id.py diff --git a/application/costumers/migrations/0003_alter_costumer_social_media.py b/application/costumers/migrations/0003_alter_costumer_social_media.py new file mode 100644 index 00000000..95130210 --- /dev/null +++ b/application/costumers/migrations/0003_alter_costumer_social_media.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.1 on 2025-11-08 15:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('costumers', '0002_costumer_social_media'), + ] + + operations = [ + migrations.AlterField( + model_name='costumer', + name='social_media', + field=models.CharField(blank=True, max_length=100), + ), + ] diff --git a/application/suppliers/forms.py b/application/suppliers/forms.py index 13b387f8..d74140d7 100644 --- a/application/suppliers/forms.py +++ b/application/suppliers/forms.py @@ -12,7 +12,7 @@ class Meta: 'mail': forms.TextInput(attrs={'class': 'form-control'}), 'phone': forms.TextInput(attrs={'class': 'form-control'}), 'site': forms.TextInput(attrs={'class': 'form-control'}), - 'document_id': forms.TextInput(attrs={'class': 'form-control'}), + 'document_id': forms.TextInput(attrs={'class': 'form-control','maxlength': '20'}), 'contact': forms.TextInput(attrs={'class': 'form-control'}), 'contact_phone': forms.TextInput(attrs={'class': 'form-control'}), 'address': forms.TextInput(attrs={'class': 'form-control'}), @@ -27,8 +27,8 @@ class Meta: 'phone': 'Telefone', 'site': 'Site/MediaSocial', 'document_id': 'CPF/CNPJ', - 'contact': 'Representante/Vendedor', - 'contact_phone': 'Contato Representante/Vendedor', + 'contact': 'Vendedor', + 'contact_phone': 'Contato Vendedor', 'address': 'Endereço', 'city': 'Cidade', 'state': 'Estado', diff --git a/application/suppliers/migrations/0003_alter_supplier_address_alter_supplier_contact_and_more.py b/application/suppliers/migrations/0003_alter_supplier_address_alter_supplier_contact_and_more.py new file mode 100644 index 00000000..c3bc0279 --- /dev/null +++ b/application/suppliers/migrations/0003_alter_supplier_address_alter_supplier_contact_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.1 on 2025-11-08 15:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('suppliers', '0002_supplier_address_supplier_city_supplier_contact_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='supplier', + name='address', + field=models.CharField(blank=True, max_length=50), + ), + migrations.AlterField( + model_name='supplier', + name='contact', + field=models.CharField(blank=True, max_length=20), + ), + migrations.AlterField( + model_name='supplier', + name='document_id', + field=models.CharField(blank=True, max_length=20), + ), + ] diff --git a/application/suppliers/migrations/0004_alter_supplier_contact_alter_supplier_document_id.py b/application/suppliers/migrations/0004_alter_supplier_contact_alter_supplier_document_id.py new file mode 100644 index 00000000..a5e813c8 --- /dev/null +++ b/application/suppliers/migrations/0004_alter_supplier_contact_alter_supplier_document_id.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.1 on 2025-11-08 15:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('suppliers', '0003_alter_supplier_address_alter_supplier_contact_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='supplier', + name='contact', + field=models.CharField(blank=True, max_length=50), + ), + migrations.AlterField( + model_name='supplier', + name='document_id', + field=models.CharField(blank=True, max_length=15), + ), + ] diff --git a/application/suppliers/models.py b/application/suppliers/models.py index 3f79d910..d3b87bc3 100644 --- a/application/suppliers/models.py +++ b/application/suppliers/models.py @@ -9,7 +9,7 @@ class Supplier(models.Model): document_id = models.CharField(max_length=15, blank=True) contact = models.CharField(max_length=50, blank=True) contact_phone = models.CharField(max_length=20, blank=True) - address = models.CharField(max_length=300, blank=True) + address = models.CharField(max_length=50, blank=True) city = models.CharField(max_length=30, blank=True) state = models.CharField(max_length=2, blank=True) zip_code = models.CharField(max_length=10, blank=True) diff --git a/application/suppliers/templates/supplier_detail.html b/application/suppliers/templates/supplier_detail.html index 0d420aee..32ce2521 100644 --- a/application/suppliers/templates/supplier_detail.html +++ b/application/suppliers/templates/supplier_detail.html @@ -4,10 +4,18 @@

    Detalhes do Fornecedor

    +

    {{ object.name }}

    -

    {{ object.description }}

    +

    {{ object.mail }}

    +

    {{ object.phone }}

    +

    {{ object.document_id }}

    +

    {{ object.address }}

    +

    {{ object.city }}

    +

    {{ object.state }}

    +

    {{ object.zip_code }}

    +

    {{ object.description }}

    diff --git a/application/suppliers/templates/supplier_list.html b/application/suppliers/templates/supplier_list.html index c28cf579..cf8eaeec 100644 --- a/application/suppliers/templates/supplier_list.html +++ b/application/suppliers/templates/supplier_list.html @@ -38,11 +38,8 @@ Telefone Site/MediaSocial CPF/CNPJ - Representante/Vendedor - Contato Representante/Vendedor - Cidade - Estado - Ações + Vendedor + Contato Vendedor @@ -54,7 +51,14 @@ {{ supplier.name }} - {{ supplier.description }} + {{ supplier.mail }} + {{ supplier.phone }} + {{ supplier.site }} + {{ supplier.document_id }} + {{ supplier.contact }} + {{ supplier.contact_phone }} + {{ supplier.contact_city }} + {{ supplier.contact_state }} From cee4367fa8f5f6ddb5eca8e38e8b2219a2bb2805 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 20:41:08 -0300 Subject: [PATCH 11/12] Corrigido nome do arquivo a ser exportado --- application/products/views.py | 2 +- application/suppliers/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/products/views.py b/application/products/views.py index 30ceada3..bc308edb 100644 --- a/application/products/views.py +++ b/application/products/views.py @@ -85,7 +85,7 @@ class ProductRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView) def products_export(request): response = HttpResponse(content_type="text/csv") - response["Content-Disposition"] = 'attachment; filename="clientes.csv"' + response["Content-Disposition"] = 'attachment; filename="produtos.csv"' writer = csv.writer(response) writer.writerow(["Título", "Categoria", "Marca", "Descrição", "Número de Série", "Preço de Custo", "Preço de Venda"]) diff --git a/application/suppliers/views.py b/application/suppliers/views.py index 56a9978d..97a0ca2d 100644 --- a/application/suppliers/views.py +++ b/application/suppliers/views.py @@ -64,7 +64,7 @@ class SupplierRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView def suppliers_export(request): response = HttpResponse(content_type="text/csv") - response["Content-Disposition"] = 'attachment; filename="clientes.csv"' + response["Content-Disposition"] = 'attachment; filename="fornecedores.csv"' writer = csv.writer(response) writer.writerow(["Nome", "Descrição"]) From 34a9230d5b5b056ae873809f1ee19828ae25b360 Mon Sep 17 00:00:00 2001 From: Fernando Sousa Date: Sat, 8 Nov 2025 21:52:31 -0300 Subject: [PATCH 12/12] =?UTF-8?q?Acertando=20produtos.=20Faltam=20campos?= =?UTF-8?q?=20na=20cria=C3=A7=C3=A3o=20do=20produto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/products/admin.py | 2 +- application/products/forms.py | 8 +++++- ...product_color_product_size_product_type.py | 28 +++++++++++++++++++ application/products/models.py | 3 ++ .../products/templates/product_detail.html | 3 ++ .../products/templates/product_list.html | 6 ++++ application/products/views.py | 2 +- 7 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 application/products/migrations/0002_product_color_product_size_product_type.py diff --git a/application/products/admin.py b/application/products/admin.py index 2d291021..e6e9c0ef 100644 --- a/application/products/admin.py +++ b/application/products/admin.py @@ -3,7 +3,7 @@ class ProductAdmin(admin.ModelAdmin): - list_display = ('title', 'serie_number',) + list_display = ('title', 'serie_number', 'color') search_fields = ('title',) diff --git a/application/products/forms.py b/application/products/forms.py index 87571d98..03d3e93e 100644 --- a/application/products/forms.py +++ b/application/products/forms.py @@ -10,7 +10,10 @@ class Meta: widgets = { 'title': forms.TextInput(attrs={'class': 'form-control'}), 'category': forms.Select(attrs={'class': 'form-control'}), - 'brand': forms.Select(attrs={'class': 'form-control'}), + 'color': forms.TextInput(attrs={'class': 'form-control'}), + 'size': forms.TextInput(attrs={'class': 'form-control'}), + 'type': forms.TextInput(attrs={'class': 'form-control'}), + 'brand': forms.Select(attrs={'class': 'form-control'}), 'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}), 'serie_number': forms.TextInput(attrs={'class': 'form-control'}), 'cost_price': forms.NumberInput(attrs={'class': 'form-control'}), @@ -19,6 +22,9 @@ class Meta: labels = { 'title': 'Título', 'category': 'Categoria', + 'color': 'Cor', + 'size': 'Tamanho', + 'type': 'Tipo', 'brand': 'Marca', 'description': 'Descrição', 'serie_number': 'Número de Série', diff --git a/application/products/migrations/0002_product_color_product_size_product_type.py b/application/products/migrations/0002_product_color_product_size_product_type.py new file mode 100644 index 00000000..2c64ca24 --- /dev/null +++ b/application/products/migrations/0002_product_color_product_size_product_type.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.1 on 2025-11-09 00:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('products', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='color', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='product', + name='size', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='product', + name='type', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/application/products/models.py b/application/products/models.py index 98afc49c..10881306 100644 --- a/application/products/models.py +++ b/application/products/models.py @@ -7,6 +7,9 @@ class Product(models.Model): title = models.CharField(max_length=500) category = models.ForeignKey(Category, on_delete=models.PROTECT, related_name='products') brand = models.ForeignKey(Brand, on_delete=models.PROTECT, related_name='products') + color = models.TextField(null=True, blank=True) + size = models.TextField(null=True, blank=True) + type = models.TextField(null=True, blank=True) description = models.TextField(null=True, blank=True) serie_number = models.CharField(max_length=200, null=True, blank=True) cost_price = models.DecimalField(max_digits=20, decimal_places=2) diff --git a/application/products/templates/product_detail.html b/application/products/templates/product_detail.html index 8a1fb578..87ef8429 100644 --- a/application/products/templates/product_detail.html +++ b/application/products/templates/product_detail.html @@ -8,6 +8,9 @@

    Detalhes do Produto

    {{ object.title }}

    Categoria: {{ object.category }}

    +

    Cor: {{ object.color }}

    +

    Tamanho: {{ object.size }}

    +

    Tipo: {{ object.type }}

    Marca: {{ object.brand }}

    {{ object.description }}

    Número de Série: {{ object.serie_number }}

    diff --git a/application/products/templates/product_list.html b/application/products/templates/product_list.html index 30cfde30..4329d789 100644 --- a/application/products/templates/product_list.html +++ b/application/products/templates/product_list.html @@ -65,6 +65,9 @@ ID Título Categoria + Cor + Tamanho + Tipo Marca Preço de Custo Preço de Venda @@ -83,6 +86,9 @@ {{ product.title }} {{ product.category }} + {{ product.color }} + {{ product.size }} + {{ product.type }} {{ product.brand }} R$ {{ product.cost_price }} R$ {{ product.selling_price }} diff --git a/application/products/views.py b/application/products/views.py index bc308edb..a64c4c44 100644 --- a/application/products/views.py +++ b/application/products/views.py @@ -90,7 +90,7 @@ def products_export(request): writer.writerow(["Título", "Categoria", "Marca", "Descrição", "Número de Série", "Preço de Custo", "Preço de Venda"]) for c in models.Product.objects.all(): - writer.writerow([c.title, c.category, c.brand, c.description, c.serie_number, c.cost_price, c.selling_price]) + writer.writerow([c.title, c.category, c.brand, c.color , c.size, c.type, c.description, c.serie_number, c.cost_price, c.selling_price]) return response