From 9bf1b3b95a8a529425b01cfd2b21ad50fa930293 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 9 Oct 2014 19:34:51 -0400 Subject: [PATCH] Improve the settings method, allow for execution of mayan-edms.py without an existing local.py file --- .gitignore | 2 +- mayan/apps/main/management/commands/initialsetup.py | 1 + mayan/bin/mayan-edms.py | 2 +- mayan/settings/__init__.py | 5 ++++- mayan/settings/base.py | 7 ++++--- mayan/settings/development.py | 5 +++-- mayan/settings/development_ddt.py | 5 +++-- mayan/settings/production.py | 8 ++++++-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index f9b3804eaf..841b0e9dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,4 @@ gpg_home/ .idea/ static_collected/ *egg-info* -mayan/settings/local.py +mayan/settings/local.py diff --git a/mayan/apps/main/management/commands/initialsetup.py b/mayan/apps/main/management/commands/initialsetup.py index d41e7a2afe..524b7a55fc 100644 --- a/mayan/apps/main/management/commands/initialsetup.py +++ b/mayan/apps/main/management/commands/initialsetup.py @@ -16,6 +16,7 @@ class Command(management.BaseCommand): with open(os.path.join(settings.BASE_DIR, 'mayan', 'settings', 'local.py'), 'w+') as file_object: file_object.write('\n'.join([ 'from __future__ import absolute_import', + '', 'from .base import *', '', "SECRET_KEY = '{0}'".format(self._generate_secret_key()), diff --git a/mayan/bin/mayan-edms.py b/mayan/bin/mayan-edms.py index 32d8e4f7c0..c8d9c5d18b 100755 --- a/mayan/bin/mayan-edms.py +++ b/mayan/bin/mayan-edms.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mayan.settings.local") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mayan.settings") from django.core.management import execute_from_command_line diff --git a/mayan/settings/__init__.py b/mayan/settings/__init__.py index e13328181e..a340fdd16e 100644 --- a/mayan/settings/__init__.py +++ b/mayan/settings/__init__.py @@ -1,3 +1,6 @@ from __future__ import absolute_import -from .base import * +try: + from .local import * # NOQA +except ImportError: + from .base import * # NOQA diff --git a/mayan/settings/base.py b/mayan/settings/base.py index 1ba427270c..5012d4ad32 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -34,7 +34,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( - #Django + # Django 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.auth', @@ -204,7 +204,8 @@ STATICFILES_FINDERS = ( # --------- Django compressor ------------- COMPRESS_PARSER = 'compressor.parser.HtmlParser' -COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter', 'compressor.filters.cssmin.CSSMinFilter'] +COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter', + 'compressor.filters.cssmin.CSSMinFilter'] COMPRESS_ENABLED = False # ---------- Django sendfile -------------- SENDFILE_BACKEND = 'sendfile.backends.simple' @@ -261,5 +262,5 @@ REST_FRAMEWORK = { CELERY_TIMEZONE = 'UTC' CELERY_ENABLE_UTC = True CELERY_ALWAYS_EAGER = True -#------------ CORS ------------ +# ------------ CORS ------------ CORS_ORIGIN_ALLOW_ALL = True diff --git a/mayan/settings/development.py b/mayan/settings/development.py index 2c052b9743..386cad20eb 100644 --- a/mayan/settings/development.py +++ b/mayan/settings/development.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -from .base import * +from . import * # NOQA DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -19,7 +19,8 @@ INSTALLED_APPS += ( 'django_extensions', ) -# Stop debug toolbar patching! (see https://github.com/django-debug-toolbar/django-debug-toolbar/issues/524) +# Stop debug toolbar patching! +# see https://github.com/django-debug-toolbar/django-debug-toolbar/issues/524 TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.debug',) WSGI_AUTO_RELOAD = True diff --git a/mayan/settings/development_ddt.py b/mayan/settings/development_ddt.py index 49804baca4..37b261c268 100644 --- a/mayan/settings/development_ddt.py +++ b/mayan/settings/development_ddt.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -from .base import * +from . import * # NOQA DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -20,7 +20,8 @@ INSTALLED_APPS += ( 'debug_toolbar' ) -# Stop debug toolbar patching! (see https://github.com/django-debug-toolbar/django-debug-toolbar/issues/524) +# Stop debug toolbar patching! +# see https://github.com/django-debug-toolbar/django-debug-toolbar/issues/524 DEBUG_TOOLBAR_PATCH_SETTINGS = False TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.debug',) diff --git a/mayan/settings/production.py b/mayan/settings/production.py index b8b0de1a1f..75d2b62528 100644 --- a/mayan/settings/production.py +++ b/mayan/settings/production.py @@ -1,5 +1,9 @@ from __future__ import absolute_import -from .local import * + +from . import * # NOQA DEBUG = False -ALLOWED_HOSTS = ['*'] # Update this accordingly; https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts + +# Update this accordingly; +# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts +ALLOWED_HOSTS = ['*']