From 11f9f9c8069b1ea2137b7a6e361ec5ba4afa6a8d Mon Sep 17 00:00:00 2001 From: Ivo Branco Date: Mon, 4 Dec 2023 16:21:50 +0000 Subject: [PATCH] refactor: settings from env to yaml Instead of reading settings from env file read them from an yaml file. Use sqlite for testing. Remove the restart always on docker compose, so the project want start on laptop next reboot. Remove python-decouple package as dependency. --- .github/workflows/django.yml | 3 - .gitignore | 2 - Makefile | 2 +- README.md | 6 -- config.yml | 9 ++ docker/Dockerfile | 2 + docker/docker-compose-app.yml | 2 - docker/docker-compose-dependencies.yml | 15 ++- nau_financial_manager/settings.py | 142 +++++++++++++++++-------- nau_financial_manager/test.py | 9 ++ nau_financial_manager/urls.py | 8 +- poetry.lock | 25 +++-- pyproject.toml | 1 - sample-dev.env | 36 ------- wait-for-mysql.sh | 2 +- 15 files changed, 139 insertions(+), 125 deletions(-) create mode 100644 config.yml create mode 100644 nau_financial_manager/test.py delete mode 100644 sample-dev.env diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index f45f710..a5e6700 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -17,8 +17,5 @@ jobs: - name: Setup Poetry run: make install-poetry install-packages - - name: Get all containers up and running - run: cp sample-dev.env .env; make hr-docker - - name: Run Django tests run: make test diff --git a/.gitignore b/.gitignore index 1178587..7e91c20 100644 --- a/.gitignore +++ b/.gitignore @@ -160,9 +160,7 @@ pyrightconfig.json # Ignore all local history of files .history .ionide -.env .python-version -.env .vscode/settings.json db.sqlite3 diff --git a/Makefile b/Makefile index 5334c4b..4ce0307 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SRC_DIR = src TEST_DIR = tests POETRY_RUN = poetry run DOCKER_COMPOSE = docker-compose -TEST_CMD = $(POETRY_RUN) python manage.py test +TEST_CMD = $(POETRY_RUN) python manage.py test --settings=nau_financial_manager.test LINT_CMD = $(POETRY_RUN) black . PRE_COMMIT = $(POETRY_RUN) pre-commit run --all-files RUN_CMD = $(POETRY_RUN) python manage.py runserver diff --git a/README.md b/README.md index c036978..5be4200 100644 --- a/README.md +++ b/README.md @@ -76,12 +76,6 @@ poetry env use 3.11.4 poetry shell ``` -## Create .env file for enviromnent desired - -```bash -cp sample-dev.env .env -``` - ## Run for DEV Start the app's dependencies services: diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..78e6056 --- /dev/null +++ b/config.yml @@ -0,0 +1,9 @@ +# This is default configuration settings used to development purposes. +# We can override any default Django setting. +# The good default setting value should be the default value of the +# +# CONFIG.get("KEY", ) +# + +# Currently we are just enforcing the debug. +DEBUG: True diff --git a/docker/Dockerfile b/docker/Dockerfile index bf30861..36c9718 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -58,4 +58,6 @@ COPY poetry.lock pyproject.toml /app/ # Install packages via poetry: RUN poetry install --verbose +ENV FINANCIAL_MANAGER_CFG=/app/config.yml + USER ${USER}:${USER} diff --git a/docker/docker-compose-app.yml b/docker/docker-compose-app.yml index 7192580..5dfa7fe 100644 --- a/docker/docker-compose-app.yml +++ b/docker/docker-compose-app.yml @@ -4,12 +4,10 @@ services: nau-financial-app: container_name: nau-financial-app - restart: always command: sh -c './wait-for-mysql.sh && python manage.py runserver 0.0.0.0:8000' build: context: ../ dockerfile: docker/Dockerfile - env_file: ../.env # on docker mode change use the container directly environment: - DB_HOST=nau-database-mysql diff --git a/docker/docker-compose-dependencies.yml b/docker/docker-compose-dependencies.yml index 17af046..63c0cc3 100755 --- a/docker/docker-compose-dependencies.yml +++ b/docker/docker-compose-dependencies.yml @@ -3,28 +3,29 @@ version: "3.5" services: database-mysql: container_name: nau-database-mysql - restart: always image: mysql:8.1 - env_file: ../.env + environment: + - MYSQL_DATABASE=nau_db + - MYSQL_USER=nau_user + - MYSQL_USER_ROOT=root + - MYSQL_PASSWORD=nau_password + - MYSQL_ROOT_PASSWORD=nau_password hostname: database ports: - "3306:3306" redis: hostname: nau-redis - restart: always image: redis:latest ports: - "6379:6379" celery: hostname: nau-celery - restart: always build: context: ../ dockerfile: docker/Dockerfile command: celery -A nau_financial_manager worker --loglevel=info - env_file: ../.env volumes: - ../:/app depends_on: @@ -33,12 +34,10 @@ services: celery-beat: hostname: nau-celery-beat - restart: always build: context: ../ dockerfile: docker/Dockerfile command: celery -A nau_financial_manager beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler - env_file: ../.env environment: - DB_HOST=nau-database-mysql volumes: @@ -52,8 +51,6 @@ services: context: ../ dockerfile: docker/Dockerfile command: celery -A nau_financial_manager flower --port=5555 - env_file: ../.env - restart: always volumes: - ../:/app ports: diff --git a/nau_financial_manager/settings.py b/nau_financial_manager/settings.py index c8cf468..d31ff4d 100644 --- a/nau_financial_manager/settings.py +++ b/nau_financial_manager/settings.py @@ -9,17 +9,48 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ +import codecs +import copy +import os from pathlib import Path -from decouple import Csv, config +import yaml +from django.core.exceptions import ImproperlyConfigured + + +def get_env_setting(env_variable, default=None): + """Get the environment variable value or return its default value.""" + try: + return os.environ[env_variable] + except KeyError: + if default: + return default + else: + error_msg = "Set the {} environment variable".format(env_variable) + raise ImproperlyConfigured(error_msg) + + +CONFIG_FILE = get_env_setting("FINANCIAL_MANAGER_CFG", "./config.yml") + +# Load the configuration from an YAML file and expose the configurations on a `CONFIG` object. +with codecs.open(CONFIG_FILE, encoding="utf-8") as f: + CONFIG = yaml.safe_load(f) + + # Add the key/values from config into the global namespace of this module. + __config_copy__ = copy.deepcopy(CONFIG) + + vars().update(__config_copy__) + BASE_DIR = Path(__file__).resolve().parent.parent -SECRET_KEY = config("SECRET_KEY") +DEBUG = CONFIG.get("DEBUG", False) -DEBUG = config("DEBUG", default=False, cast=bool) +SECRET_KEY = CONFIG.get("SECRET_KEY", "change-me") +if SECRET_KEY == "change-me" and not DEBUG: + raise ImproperlyConfigured("For security reasons you need to change the 'SECRET_KEY'.") -ALLOWED_HOSTS = config("ALLOWED_HOSTS", cast=Csv(), default="localhost") +ALLOWED_HOSTS = CONFIG.get("ALLOWED_HOSTS", ["127.0.0.1", "localhost"]) DJANGO_APPS = [ "django.contrib.admin", @@ -83,16 +114,24 @@ WSGI_APPLICATION = "nau_financial_manager.wsgi.application" -DATABASES = { - "default": { - "ENGINE": "django.db.backends.mysql", - "NAME": config("MYSQL_DATABASE"), - "USER": config("MYSQL_USER_ROOT"), - "PASSWORD": config("MYSQL_PASSWORD"), - "HOST": config("DB_HOST"), - "PORT": config("DB_PORT"), - } -} +# The normal Django `DATABASES`` setting +DATABASES = CONFIG.get( + "DATABASES", + { + "default": { + # The DB_HOST needs to be overridden from environment variable because we have 2 modes + # of running on the development mode, one from docker and another outside docker. + # Each modes connects to MySQL host differently. + "ENGINE": get_env_setting("ENGINE", "django.db.backends.mysql"), + "NAME": get_env_setting("MYSQL_DATABASE", "nau_db"), + "USER": get_env_setting("MYSQL_USER", "nau_user"), + "PASSWORD": get_env_setting("MYSQL_PASSWORD", "nau_password"), + # Default mode it the development mode without docker + "HOST": get_env_setting("DB_HOST", "127.0.0.1"), + "PORT": get_env_setting("DB_PORT", 3306), + } + }, +) REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), @@ -105,33 +144,38 @@ ], } -CELERY_APP = "nau_financial_manager" -CELERY_BROKER_URL = config("CELERY_BROKER_URL", "redis://nau-redis:6379/0") -CELERY_RESULT_BACKEND = config("CELERY_RESULT_BACKEND", "django-db") -CELERY_CACHE_BACKEND = "default" -CELERY_TASK_TRACK_STARTED = True -CELERY_ACCEPT_CONTENT = ["application/json"] -CELERY_TASK_SERIALIZER = "json" -CELERY_RESULT_SERIALIZER = "json" -CELERY_RESULTS_EXTENDED = True -CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler" +# Celery settings +CELERY_APP = CONFIG.get("CELERY_APP", "nau_financial_manager") +CELERY_BROKER_URL = CONFIG.get("CELERY_BROKER_URL", "redis://nau-redis:6379/0") +CELERY_RESULT_BACKEND = CONFIG.get("CELERY_RESULT_BACKEND", "django-db") +CELERY_CACHE_BACKEND = CONFIG.get("CELERY_CACHE_BACKEND", "default") +CELERY_TASK_TRACK_STARTED = CONFIG.get("CELERY_TASK_TRACK_STARTED", True) +CELERY_ACCEPT_CONTENT = CONFIG.get("CELERY_ACCEPT_CONTENT", ["application/json"]) +CELERY_TASK_SERIALIZER = CONFIG.get("CELERY_TASK_SERIALIZER", "json") +CELERY_RESULT_SERIALIZER = CONFIG.get("CELERY_RESULT_SERIALIZER", "json") +CELERY_RESULTS_EXTENDED = CONFIG.get("CELERY_RESULTS_EXTENDED", True) +CELERY_BEAT_SCHEDULER = CONFIG.get("CELERY_BEAT_SCHEDULER", "django_celery_beat.schedulers:DatabaseScheduler") # WORKAROUND TO CELERY USING MYSQL DJANGO_CELERY_RESULTS_TASK_ID_MAX_LENGTH = 191 - -REDIS_URL = config("REDIS_URL", "redis://localhost:6379/") -REDIS_HOST = config("REDIS_HOST", "nau-redis") -REDIS_PORT = config("REDIS_PORT", 6379) -REDIS_DB = config("REDIS_DB", 0) - -CACHES = { - "default": { - "BACKEND": "django.core.cache.backends.redis.RedisCache", - "LOCATION": config("REDIS_URL", "redis://localhost:6379/"), - "KEY_PREFIX": "naufm", - "TIMEOUT": 60 * 15, # in seconds: 60 * 15 (15 minutes) - } -} +# Django Cache settings +# +# By default it uses the Redis as Django Cache. +# +# The next configuration is used for development proposes. +# If you need to change this for a specific environment update the `CACHES` key +# on the `FINANCIAL_MANAGER_CFG` yaml file. +CACHES = CONFIG.get( + "CACHES", + { + "default": { + "BACKEND": "django.core.cache.backends.redis.RedisCache", + "LOCATION": "redis://localhost:6379/0", + "KEY_PREFIX": "naufm", + "TIMEOUT": 60 * 15, # in seconds: 60 * 15 (15 minutes) + } + }, +) AUTH_PASSWORD_VALIDATORS = [ { @@ -160,14 +204,18 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" -# Transcation processor settings -TRANSACTION_PROCESSOR_URL = config("TRANSACTION_PROCESSOR_URL", "") -IVA_VACITM1_FIELD = config("IVA_VACITM1_FIELD", "") -GEOGRAPHIC_ACTIVITY_VACBPR_FIELD = config("GEOGRAPHIC_ACTIVITY_VACBPR_FIELD", "") -USER_PROCESSOR_AUTH = config("USER_PROCESSOR_AUTH", "") -USER_PROCESSOR_PASSWORD = config("USER_PROCESSOR_PASSWORD", "") +# Transaction processor settings +TRANSACTION_PROCESSOR_URL = CONFIG.get("TRANSACTION_PROCESSOR_URL", "") +IVA_VACITM1_FIELD = CONFIG.get("IVA_VACITM1_FIELD", "NOR") +GEOGRAPHIC_ACTIVITY_VACBPR_FIELD = CONFIG.get("GEOGRAPHIC_ACTIVITY_VACBPR_FIELD", "CON") +USER_PROCESSOR_AUTH = CONFIG.get("USER_PROCESSOR_AUTH", "") +USER_PROCESSOR_PASSWORD = CONFIG.get("USER_PROCESSOR_PASSWORD", "") # Invoice host information -INVOICE_HOST_URL = config("INVOICE_HOST_URL", "") -INVOICE_HOST_AUTH = config("INVOICE_HOST_AUTH", "") -INVOICE_HOST_PASSWORD = config("INVOICE_HOST_PASSWORD", "") +INVOICE_HOST_URL = CONFIG.get("INVOICE_HOST_URL", "") +INVOICE_HOST_AUTH = CONFIG.get("INVOICE_HOST_AUTH", "") +INVOICE_HOST_PASSWORD = CONFIG.get("INVOICE_HOST_PASSWORD", "") + +SWAGGER_PROJECT_NAME = CONFIG.get("SWAGGER_PROJECT_NAME", "Nau Financial Manager") +SWAGGER_PROJECT_VERSION = CONFIG.get("SWAGGER_PROJECT_VERSION", "1.0.0") +SWAGGER_DESCRIPTION = CONFIG.get("SWAGGER_DESCRIPTION", "API for Nau Financial Manager") diff --git a/nau_financial_manager/test.py b/nau_financial_manager/test.py new file mode 100644 index 0000000..66554e4 --- /dev/null +++ b/nau_financial_manager/test.py @@ -0,0 +1,9 @@ +from .settings import * + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': "test.db", + 'ATOMIC_REQUESTS': True, + }, +} diff --git a/nau_financial_manager/urls.py b/nau_financial_manager/urls.py index d3096d9..a122b62 100644 --- a/nau_financial_manager/urls.py +++ b/nau_financial_manager/urls.py @@ -14,7 +14,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from decouple import config +from django.conf import settings from django.contrib import admin from django.urls import include, path from drf_yasg import openapi @@ -23,9 +23,9 @@ schema_view = get_schema_view( openapi.Info( - title=config("SWAGGER_PROJECT_NAME", default="Your project name"), - default_version=config("SWAGGER_PROJECT_VERSION", default="1.0.0"), - description=config("SWAGGER_DESCRIPTION", default="Your project description"), + title=settings.SWAGGER_PROJECT_NAME, + default_version=settings.SWAGGER_PROJECT_VERSION, + description=settings.SWAGGER_DESCRIPTION, ), public=True, permission_classes=(permissions.AllowAny,), diff --git a/poetry.lock b/poetry.lock index 75b61fb..a98120b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. [[package]] name = "amqp" @@ -976,17 +976,6 @@ files = [ [package.dependencies] six = ">=1.5" -[[package]] -name = "python-decouple" -version = "3.8" -description = "Strict separation of settings from code." -optional = false -python-versions = "*" -files = [ - {file = "python-decouple-3.8.tar.gz", hash = "sha256:ba6e2657d4f376ecc46f77a3a615e058d93ba5e465c01bbe57289bfb7cce680f"}, - {file = "python_decouple-3.8-py3-none-any.whl", hash = "sha256:d0d45340815b25f4de59c974b855bb38d03151d81b037d9e3f463b0c9f8cbd66"}, -] - [[package]] name = "pytz" version = "2023.3.post1" @@ -1010,6 +999,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1017,8 +1007,15 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1035,6 +1032,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1042,6 +1040,7 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1287,4 +1286,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10.2" -content-hash = "b187091d553caf4d4e77ac88047e700d61de380b151c17c0bc9255153ba0b139" +content-hash = "7274a7e9da1df349bef9ddc5d7baf8d2d42286d82e9e5673d81820195a4b2df2" diff --git a/pyproject.toml b/pyproject.toml index 4895fee..eb63139 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,6 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.10.2" django = "^4.2.4" -python-decouple = "^3.8" pre-commit = "^3.3.3" black = "^23.7.0" flake8 = "^6.1.0" diff --git a/sample-dev.env b/sample-dev.env deleted file mode 100644 index 415bd94..0000000 --- a/sample-dev.env +++ /dev/null @@ -1,36 +0,0 @@ -SECRET_KEY=django-insecure-89x(2gbrxdo8z-7g3no54j2eagxr=awkrrr*g&hv*#uwh5^ui1 -DEBUG=True -ALLOWED_HOSTS=localhost,127.0.0.1 - -# DATABASE -MYSQL_DATABASE=nau_db -MYSQL_USER=nau_user -MYSQL_USER_ROOT=root -MYSQL_PASSWORD=nau_password -MYSQL_ROOT_PASSWORD=nau_password -DB_HOST=127.0.0.1 -DB_PORT=3306 - -SWAGGER_PROJECT_NAME=Nau Financial Manager -SWAGGER_DESCRIPTION=API for Nau Financial Manager -SWAGGER_SERVE_INCLUDE_SCHEMA=False -SWAGGER_VERSION=1.0.0 - -CELERY_BROKER_URL = 'redis://nau-redis:6379/0' -CELERY_RESULT_BACKEND = 'django-db' - -REDIS_URL = redis://localhost:6379/ -REDIS_HOST = 'nau-redis' -REDIS_PORT = 6379 -REDIS_DB = 0 - -TRANSACTION_PROCESSOR_URL = "" -IVA_VACITM1_FIELD = "NOR" -GEOGRAPHIC_ACTIVITY_VACBPR_FIELD = "CON" -USER_PROCESSOR_AUTH = "" -USER_PROCESSOR_PASSWORD = "" - - -INVOICE_HOST_URL = https://www.ilink.pt/ilink-api/api/v1/pt/apps/documents -INVOICE_HOST_AUTH = "" -INVOICE_HOST_PASSWORD = "" diff --git a/wait-for-mysql.sh b/wait-for-mysql.sh index 49217db..43719c8 100755 --- a/wait-for-mysql.sh +++ b/wait-for-mysql.sh @@ -1,7 +1,7 @@ #!/bin/bash # wait-for-mysql.sh -until mycli -h $DB_HOST -u $MYSQL_USER -p $MYSQL_PASSWORD -e 'SELECT 1' --myclirc /tmp/.myclirc; do +until mycli -h $DB_HOST -u nau_user -p nau_password -e 'SELECT 1' --myclirc /tmp/.myclirc; do >&2 echo "MySQL is unavailable - sleeping" sleep 1 done