From 1656d2e2ec81338f2e1762dbd187106aaf4b4be0 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Fri, 1 Nov 2019 22:57:40 -0400 Subject: [PATCH] Start using Goodconf. --- .gitignore | 1 + mypy.ini | 3 +++ requirements.in | 1 + requirements.txt | 3 +++ settings/base.py | 7 +++++-- settings/conf.py | 10 ++++++++++ settings/development.py | 2 -- 7 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 settings/conf.py diff --git a/.gitignore b/.gitignore index bfe8432..7978c51 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,7 @@ assets/fonts assets/images/img assets/images/node_modules +settings.yaml settings/_*.py conductor/templates/sitemap.xml media diff --git a/mypy.ini b/mypy.ini index 178b053..10c9227 100644 --- a/mypy.ini +++ b/mypy.ini @@ -26,6 +26,9 @@ ignore_missing_imports = True [mypy-faker.*] ignore_missing_imports = True +[mypy-goodconf.*] +ignore_missing_imports = True + [mypy-google.*] ignore_missing_imports = True diff --git a/requirements.in b/requirements.in index a8bfadc..fcf4f5c 100644 --- a/requirements.in +++ b/requirements.in @@ -6,6 +6,7 @@ django-anymail==3.0 django-localflavor==2.0 django-storages==1.6.6 django-waffle==0.15.1 +goodconf[yaml]==1.0.0 google-api-python-client==1.6.4 # google-auth-httplib2 has an adapter to make google-auth creds work # with the Python client. diff --git a/requirements.txt b/requirements.txt index 9579438..440fcef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,6 +20,7 @@ django-waffle==0.15.1 django==2.0.9 docutils==0.14 # via botocore gevent==1.4.0 # via wal-e +goodconf[yaml]==1.0.0 google-api-python-client==1.6.4 google-auth-httplib2==0.0.3 google-auth-oauthlib==0.2.0 @@ -40,6 +41,8 @@ requests-oauthlib==1.2.0 # via google-auth-oauthlib requests==2.9.1 rollbar==0.14.7 rsa==4.0 # via google-auth, oauth2client +ruamel.yaml.clib==0.2.0 # via ruamel.yaml +ruamel.yaml==0.16.5 # via goodconf s3transfer==0.1.13 # via boto3 six==1.12.0 # via django-anymail, google-api-python-client, google-auth, oauth2client, python-dateutil, rollbar stripe==2.11.0 diff --git a/settings/base.py b/settings/base.py index f80f2c5..ddc0f9c 100644 --- a/settings/base.py +++ b/settings/base.py @@ -5,14 +5,17 @@ import conductor +from .conf import config + +config.load() + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.dirname(BASE_DIR) SECRET_KEY = "y$l*8=9d0b^nbf4c#vs+z=d)vb(3rsgvcx!+2as@f5f2s*#x=q" -# Other settings must explicitly opt-in for debug mode. -DEBUG = False +DEBUG = config.DEBUG DATABASES = { "default": { diff --git a/settings/conf.py b/settings/conf.py new file mode 100644 index 0000000..6a70325 --- /dev/null +++ b/settings/conf.py @@ -0,0 +1,10 @@ +from goodconf import GoodConf, Value + + +class Config(GoodConf): + """Configuration settings for College Conductor""" + + DEBUG = Value(default=False, help="Toggle debugging.") + + +config = Config(default_files=["/etc/conductor/settings.yaml", "settings.yaml"]) diff --git a/settings/development.py b/settings/development.py index 245ccbb..d6fde3c 100644 --- a/settings/development.py +++ b/settings/development.py @@ -1,7 +1,5 @@ from settings.base import * # noqa -DEBUG = True - INTERNAL_IPS = ("127.0.0.1",) INSTALLED_APPS += ("debug_toolbar",) # noqa MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa