Merge branch 'feature/django-settings' into develop

This commit is contained in:
rascencio 2015-11-02 16:03:00 -06:00
commit 579961208d
10 changed files with 64 additions and 57 deletions

4
.gitignore vendored
View file

@ -28,3 +28,7 @@ ungleich.db
*~* *~*
secret-key secret-key
.idea/
.env

View file

@ -1,13 +0,0 @@
# from dynamicweb.settings import SITE_ROOT
DEBUG = True
TEMPLATE_DEBUG = DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_name',
'USER': 'username',
'PASSWORD': 'password',
}
}

View file

@ -8,22 +8,26 @@ import os
import logging import logging
import django.db.backends.postgresql_psycopg2 import django.db.backends.postgresql_psycopg2
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
# dotenv
import dotenv
gettext = lambda s: s gettext = lambda s: s
def env(env_name):
return os.environ.get(env_name)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.abspath(
os.path.join(os.path.dirname(__file__), "../.."),
)
# load .env file
dotenv.read_dotenv("{0}/.env".format(PROJECT_DIR))
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
ADMINS = (
('Nico Schottelius', 'nico.schottelius@ungleich.ch'),
)
# ('Sanghee Kim', 'sanghee.kim@ungleich.ch'),
MANAGERS = ADMINS
SITE_ID = 1 SITE_ID = 1
APP_ROOT_ENDPOINT = "/" APP_ROOT_ENDPOINT = "/"
@ -35,18 +39,7 @@ LOGIN_REDIRECT_URL = None
EMAIL_HOST="localhost" EMAIL_HOST="localhost"
EMAIL_PORT=25 EMAIL_PORT=25
SECRET_KEY_FILE = os.path.join(BASE_DIR, "secret-key") SECRET_KEY = env('DJANGO_SECRET_KEY')
with open(SECRET_KEY_FILE, "r") as f:
SECRET_KEY = f.read().strip()
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = [
".ungleich.ch",
"digital.glarus.ungleich.ch" ,
]
# Application definition # Application definition
@ -116,7 +109,6 @@ MIDDLEWARE_CLASSES = (
'cms.middleware.toolbar.ToolbarMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware', 'cms.middleware.language.LanguageCookieMiddleware',
) )
# 'django.middleware.security.SecurityMiddleware',
ROOT_URLCONF = 'dynamicweb.urls' ROOT_URLCONF = 'dynamicweb.urls'
@ -155,15 +147,13 @@ TEMPLATE_CONTEXT_PROCESSORS = (
) )
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'), os.path.join(PROJECT_DIR, 'templates'),
) )
CMS_TEMPLATES_DIR = { CMS_TEMPLATES_DIR = {
1: os.path.join(TEMPLATE_DIRS[0], 'cms/'), 1: os.path.join(TEMPLATE_DIRS[0], 'cms/'),
} }
# Database # Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
@ -266,13 +256,6 @@ CACHES = {
} }
} }
try:
from dynamicweb.local.local_settings import *
except ImportError:
logging.warning("No local_settings file found.")
if not APP_ROOT_ENDPOINT.endswith('/'):
APP_ROOT += '/'
if LOGIN_URL is None: if LOGIN_URL is None:
LOGIN_URL = APP_ROOT_ENDPOINT + 'accounts/login/' LOGIN_URL = APP_ROOT_ENDPOINT + 'accounts/login/'
if LOGOUT_URL is None: if LOGOUT_URL is None:
@ -285,16 +268,15 @@ if LOGIN_REDIRECT_URL is None:
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
# Media files. MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = APP_ROOT_ENDPOINT + 'media/' MEDIA_URL = APP_ROOT_ENDPOINT + 'media/'
FILE_UPLOAD_PERMISSIONS = 0o644 FILE_UPLOAD_PERMISSIONS = 0o644
# Templates confs # Templates confs
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
os.path.join(BASE_DIR, "templates"), os.path.join(PROJECT_DIR, "templates"),
) )
META_SITE_PROTOCOL = 'http' META_SITE_PROTOCOL = 'http'
@ -429,8 +411,3 @@ META_SITE_TYPE = "website"
META_SITE_NAME = "ungleich" META_SITE_NAME = "ungleich"
META_INCLUDE_KEYWORDS = ["ungleich", "hosting", "switzerland", "Schweiz", "Swiss", "cdist"] META_INCLUDE_KEYWORDS = ["ungleich", "hosting", "switzerland", "Schweiz", "Swiss", "cdist"]
META_USE_SITES = True META_USE_SITES = True
try:
from .local.local_settings import *
except ImportError as e:
pass

View file

@ -0,0 +1,21 @@
from .base import *
ALLOWED_HOSTS = [
"*"
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'app.db',
}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake'
}
}
DEBUG = True

View file

@ -0,0 +1,15 @@
from .base import *
DEBUG = False
ADMINS = (
('Nico Schottelius', 'nico.schottelius@ungleich.ch'),
)
# ('Sanghee Kim', 'sanghee.kim@ungleich.ch'),
MANAGERS = ADMINS
ALLOWED_HOSTS = [
".ungleich.ch",
"digital.glarus.ungleich.ch" ,
]

View file

@ -4,7 +4,7 @@ from django.contrib import admin
from django.conf.urls.i18n import i18n_patterns from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static from django.conf.urls.static import static
from dynamicweb import settings from django.conf import settings
from hosting.views import railshosting from hosting.views import railshosting
urlpatterns = [ urlpatterns = [

View file

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dynamicweb.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dynamicweb.settings.prod")
application = get_wsgi_application() application = get_wsgi_application()

View file

@ -3,7 +3,7 @@ import os
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dynamicweb.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dynamicweb.settings.local")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line

View file

@ -56,3 +56,6 @@ gevent>=1.1a2
djangocms-page-meta djangocms-page-meta
# memcache # memcache
pylibmc pylibmc
# .env
django-dotenv