From b522b7470fee05a3d84c2aff841f3caa831da6a0 Mon Sep 17 00:00:00 2001 From: Andrey Golovizin Date: Tue, 10 Mar 2020 20:56:25 +0100 Subject: [PATCH] Set DEBUG=True with dotenv --- .env | 1 + requirements.nix | 17 +++++++++++++++++ requirements.txt | 1 + requirements_frozen.txt | 1 + src/strojnadzor/settings.py | 11 +++++++---- 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..80563d5 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +STROJNADZOR_DEBUG=1 diff --git a/requirements.nix b/requirements.nix index c96e3e3..90aa2c7 100644 --- a/requirements.nix +++ b/requirements.nix @@ -988,6 +988,23 @@ let }; }; + "python-dotenv" = python.mkDerivation { + name = "python-dotenv-0.12.0"; + src = pkgs.fetchurl { + url = "https://files.pythonhosted.org/packages/81/8b/26f807fa58582455f8ebb07f1b7473ee1a21b4671d1eaf4fecece9337e2a/python-dotenv-0.12.0.tar.gz"; + sha256 = "92b3123fb2d58a284f76cc92bfe4ee6c502c32ded73e8b051c4f6afc8b6751ed"; +}; + doCheck = commonDoCheck; + format = "pyproject"; + buildInputs = commonBuildInputs ++ [ ]; + propagatedBuildInputs = [ ]; + meta = with pkgs.stdenv.lib; { + homepage = "http://github.com/theskumar/python-dotenv"; + license = licenses.bsdOriginal; + description = "Add .env support to your django/flask apps in development and deployments"; + }; + }; + "pytz" = python.mkDerivation { name = "pytz-2019.3"; src = pkgs.fetchurl { diff --git a/requirements.txt b/requirements.txt index 21c0643..2d8ed2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,3 +21,4 @@ django-sekizai>=1.0 django-mptt>0.9 gunicorn +python-dotenv diff --git a/requirements_frozen.txt b/requirements_frozen.txt index 05dd3e9..bd6f1c9 100644 --- a/requirements_frozen.txt +++ b/requirements_frozen.txt @@ -44,6 +44,7 @@ lxml==4.5.0 openpyxl==2.4.9 Pillow==7.0.0 premailer==3.6.1 +python-dotenv==0.12.0 pytz==2019.3 requests==2.23.0 setuptools-scm==3.5.0 diff --git a/src/strojnadzor/settings.py b/src/strojnadzor/settings.py index 38bb342..917597c 100644 --- a/src/strojnadzor/settings.py +++ b/src/strojnadzor/settings.py @@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os # isort:skip +import dotenv + +dotenv.load_dotenv() gettext = lambda s: s @@ -36,9 +39,9 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__)) SECRET_KEY = "15-d*6bl(@+jfo92@=67vi1ohx%3e&^l98*bo*v$$+ms%!l(!!" # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = bool(os.getenv("STROJNADZOR_DEBUG")) -ALLOWED_HOSTS = ['.golovizin.ru', '.xn--b1abndboscb.xn--p1ai', 'localhost'] +ALLOWED_HOSTS = [".golovizin.ru", ".xn--b1abndboscb.xn--p1ai", "localhost"] # Application definition @@ -226,9 +229,9 @@ DJANGOCMS_PICTURE_RESPONSIVE_IMAGES_VIEWPORT_BREAKPOINTS = [300, 400, 576, 768] DEFAULT_FROM_EMAIL = "noreply@sologoc.com" -CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_arcs',) +CAPTCHA_NOISE_FUNCTIONS = ("captcha.helpers.noise_arcs",) CAPTCHA_FILTER_FUNCTIONS = () -CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.word_challenge' +CAPTCHA_CHALLENGE_FUNCT = "captcha.helpers.word_challenge" CAPTCHA_FONT_PATH = os.path.join(BASE_DIR, "DejaVuSans.ttf") CAPTCHA_WORDS_DICTIONARY = os.path.join(BASE_DIR, "construction.txt") CAPTCHA_LENGTH = 5