From 6a863ee5e5d80635fc744aa5d6d482f4dab923fc Mon Sep 17 00:00:00 2001 From: pwhipp Date: Wed, 9 Jul 2014 07:32:59 +1000 Subject: [PATCH] Refactored settings to support multiple sites and secrets --- mayan/settings/__init__.py | 1 + mayan/settings/dev.py | 15 ++++++++ mayan/settings/includes/.gitignore | 1 + mayan/settings/includes/__init__.py | 1 + .../includes/common.py} | 35 ++++++------------- 5 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 mayan/settings/__init__.py create mode 100644 mayan/settings/dev.py create mode 100644 mayan/settings/includes/.gitignore create mode 100644 mayan/settings/includes/__init__.py rename mayan/{settings.py => settings/includes/common.py} (90%) diff --git a/mayan/settings/__init__.py b/mayan/settings/__init__.py new file mode 100644 index 0000000000..62bff48960 --- /dev/null +++ b/mayan/settings/__init__.py @@ -0,0 +1 @@ +__author__ = 'paul' diff --git a/mayan/settings/dev.py b/mayan/settings/dev.py new file mode 100644 index 0000000000..03ecf595f6 --- /dev/null +++ b/mayan/settings/dev.py @@ -0,0 +1,15 @@ +from mayan.settings.includes.common import * + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ALLOWED_HOSTS = [] + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'mayan', + 'USER': 'mayan', + 'PASSWORD': DBPASSWORD, + 'HOST': '', + 'PORT': ''}} \ No newline at end of file diff --git a/mayan/settings/includes/.gitignore b/mayan/settings/includes/.gitignore new file mode 100644 index 0000000000..c6b649876c --- /dev/null +++ b/mayan/settings/includes/.gitignore @@ -0,0 +1 @@ +secrets.py \ No newline at end of file diff --git a/mayan/settings/includes/__init__.py b/mayan/settings/includes/__init__.py new file mode 100644 index 0000000000..62bff48960 --- /dev/null +++ b/mayan/settings/includes/__init__.py @@ -0,0 +1 @@ +__author__ = 'paul' diff --git a/mayan/settings.py b/mayan/settings/includes/common.py similarity index 90% rename from mayan/settings.py rename to mayan/settings/includes/common.py index 5862fa08d2..d34630afde 100644 --- a/mayan/settings.py +++ b/mayan/settings/includes/common.py @@ -11,25 +11,22 @@ https://docs.djangoproject.com/en/1.6/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +from django.core.exceptions import ImproperlyConfigured + + ugettext = lambda s: s BASE_DIR = os.path.abspath(os.path.dirname(__file__)) -SITE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +SITE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..//')) +try: + from .secrets import * +except ImportError: + raise ImproperlyConfigured('You need a secrets.py file - contact aaron.dennis@crossculturalconsult.com') -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'om^a(i8^6&h+umbd2%pt91cj!qu_@oztw117rgxmn(n2lp^*c!' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -TEMPLATE_DEBUG = True - -ALLOWED_HOSTS = [] +DEBUG = False +TEMPLATE_DEBUG = DEBUG # Application definition @@ -117,17 +114,7 @@ ROOT_URLCONF = 'mayan.urls' WSGI_APPLICATION = 'mayan.wsgi.application' -# Database -# https://docs.djangoproject.com/en/1.6/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'mayan', - 'USER': 'mayan', - 'PASSWORD': 'Jeeji4ah', - 'HOST': '', - 'PORT': ''}} # Internationalization # https://docs.djangoproject.com/en/1.6/topics/i18n/ @@ -154,7 +141,7 @@ import sys from django.core.urlresolvers import reverse_lazy -sys.path.append(os.path.join(BASE_DIR, 'apps')) +sys.path.append(os.path.join(BASE_DIR, '../../../apps')) PROJECT_TITLE = 'Mayan EDMS' PROJECT_NAME = 'mayan'