blob: dd8e5aa5a1acea47974c5fe3b3c71f9f4e53509b [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
Scott Bakerb9396c22014-06-16 13:58:21 -070016from django import VERSION as DJANGO_VERSION
David K. Bainbridgeab4a2eb2015-12-03 11:49:01 -080017import os
Zack Williamsc4a31302016-04-27 17:44:29 -070018import warnings
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040019
Matteo Scandolo6bc017c2017-05-25 18:37:42 -070020# Initializing xosconfig module
21from xosconfig import Config
Scott Bakerb06e3e02017-12-12 11:05:53 -080022from xosconfig.config import INITIALIZED as CONFIG_INITIALIZED
23
24# this really shouldn't be called from settings.py.
25if not CONFIG_INITIALIZED:
26 Config.init()
Scott Baker8a867eb2014-04-22 13:50:26 -070027
28GEOIP_PATH = "/usr/share/GeoIP"
Zack Williams045b63d2019-01-22 16:30:57 -070029XOS_DIR = Config.get("xos_dir")
David K. Bainbridgeab4a2eb2015-12-03 11:49:01 -080030
Matteo Scandolo6ea6a7d2016-02-29 15:46:55 -080031DEBUG = True
Tony Mack7130ac32013-03-22 21:58:00 -040032TEMPLATE_DEBUG = DEBUG
33
Matteo Scandoloecf088a2016-10-20 10:25:34 +020034# Enable CORS requests, needed to enable layered XOS
35CORS_ORIGIN_ALLOW_ALL = True
36
Tony Mack7130ac32013-03-22 21:58:00 -040037ADMINS = (
38 # ('Your Name', 'your_email@example.com'),
39)
40
Matteo Scandolo6ea6a7d2016-02-29 15:46:55 -080041# LOGIN_REDIRECT_URL = '/admin/core/user'
Zack Williams045b63d2019-01-22 16:30:57 -070042LOGIN_REDIRECT_URL = "/admin/loggedin/"
Siobhan Tullycf04fb62014-01-11 11:25:57 -050043
Tony Mack7130ac32013-03-22 21:58:00 -040044MANAGERS = ADMINS
45
Matteo Scandolo57fdb4b2019-02-06 18:27:56 -080046DB = {
47 "ENGINE": "django.db.backends.postgresql_psycopg2",
48 "NAME": Config.get("database.name"),
49 "USER": Config.get("database.username"),
50 "PASSWORD": Config.get("database.password"),
51 "HOST": "xos-db",
52 "PORT": 5432,
53}
54
55if "MIGRATIONS" in os.environ and os.environ["MIGRATIONS"] == "true":
56 DB = {
57 'ENGINE': 'django.db.backends.dummy',
Tony Mack7130ac32013-03-22 21:58:00 -040058 }
Matteo Scandolo57fdb4b2019-02-06 18:27:56 -080059
60DATABASES = {
61 'default': DB
Tony Mack7130ac32013-03-22 21:58:00 -040062}
63
Zack Williams045b63d2019-01-22 16:30:57 -070064AUTH_USER_MODEL = "core.User"
Siobhan Tully30fd4292013-05-10 08:59:56 -040065
Tony Mack7130ac32013-03-22 21:58:00 -040066# Hosts/domain names that are valid for this site; required if DEBUG is False
67# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
Scott Bakerbb885442015-02-05 09:19:25 -080068ALLOWED_HOSTS = ["*"]
Tony Mack7130ac32013-03-22 21:58:00 -040069
70# Local time zone for this installation. Choices can be found here:
71# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
72# although not all choices may be available on all operating systems.
73# In a Windows environment this must be set to your system time zone.
Zack Williams045b63d2019-01-22 16:30:57 -070074TIME_ZONE = "America/New_York"
Tony Mack7130ac32013-03-22 21:58:00 -040075
Zack Williamsc4a31302016-04-27 17:44:29 -070076# Verbose warnings when a naive datetime is used, gives a traceback
77# from: https://docs.djangoproject.com/en/1.9/topics/i18n/timezones/#code
78warnings.filterwarnings(
Zack Williams045b63d2019-01-22 16:30:57 -070079 "error",
80 r"DateTimeField .* received a naive datetime",
81 RuntimeWarning,
82 r"django\.db\.models\.fields",
83)
Zack Williamsc4a31302016-04-27 17:44:29 -070084
Tony Mack7130ac32013-03-22 21:58:00 -040085# Language code for this installation. All choices can be found here:
86# http://www.i18nguy.com/unicode/language-identifiers.html
Zack Williams045b63d2019-01-22 16:30:57 -070087LANGUAGE_CODE = "en-us"
Tony Mack7130ac32013-03-22 21:58:00 -040088
89SITE_ID = 1
90
91# If you set this to False, Django will make some optimizations so as not
92# to load the internationalization machinery.
93USE_I18N = True
94
95# If you set this to False, Django will not format dates, numbers and
96# calendars according to the current locale.
97USE_L10N = True
98
99# If you set this to False, Django will not use timezone-aware datetimes.
100USE_TZ = True
101
102# Absolute filesystem path to the directory that will hold user-uploaded files.
103# Example: "/var/www/example.com/media/"
Zack Williams045b63d2019-01-22 16:30:57 -0700104MEDIA_ROOT = "/var/www/html/files/"
Tony Mack7130ac32013-03-22 21:58:00 -0400105
106# URL that handles the media served from MEDIA_ROOT. Make sure to use a
107# trailing slash.
108# Examples: "http://example.com/media/", "http://media.example.com/"
Zack Williams045b63d2019-01-22 16:30:57 -0700109MEDIA_URL = "/files/"
Tony Mack7130ac32013-03-22 21:58:00 -0400110
111# Absolute path to the directory static files should be collected to.
112# Don't put anything in this directory yourself; store your static files
113# in apps' "static/" subdirectories and in STATICFILES_DIRS.
114# Example: "/var/www/example.com/static/"
Zack Williams045b63d2019-01-22 16:30:57 -0700115STATIC_ROOT = ""
Tony Mack7130ac32013-03-22 21:58:00 -0400116
117# URL prefix for static files.
118# Example: "http://example.com/static/", "http://static.example.com/"
Zack Williams045b63d2019-01-22 16:30:57 -0700119STATIC_URL = "/static/"
Tony Mack7130ac32013-03-22 21:58:00 -0400120
121# Additional locations of static files
Zack Williams045b63d2019-01-22 16:30:57 -0700122STATICFILES_DIRS = (XOS_DIR + "/core/static/", XOS_DIR + "/core/xoslib/static/")
Tony Mack7130ac32013-03-22 21:58:00 -0400123
124# List of finder classes that know how to find static files in
125# various locations.
126STATICFILES_FINDERS = (
Zack Williams045b63d2019-01-22 16:30:57 -0700127 "django.contrib.staticfiles.finders.FileSystemFinder",
128 "django.contrib.staticfiles.finders.AppDirectoriesFinder",
129 # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
Tony Mack7130ac32013-03-22 21:58:00 -0400130)
131
132# Make this unique, and don't share it with anybody.
Zack Williams045b63d2019-01-22 16:30:57 -0700133SECRET_KEY = "i0=a)c7_#2)5m%k_fu#%53xap$tlqc+#&z5as+bl7&)(@be_f9"
Tony Mack7130ac32013-03-22 21:58:00 -0400134
135# List of callables that know how to import templates from various sources.
136TEMPLATE_LOADERS = (
Zack Williams045b63d2019-01-22 16:30:57 -0700137 "django.template.loaders.filesystem.Loader",
138 "django.template.loaders.app_directories.Loader",
139 # 'django.template.loaders.eggs.Loader',
Tony Mack7130ac32013-03-22 21:58:00 -0400140)
141
142MIDDLEWARE_CLASSES = (
Zack Williams045b63d2019-01-22 16:30:57 -0700143 "django.middleware.common.CommonMiddleware",
144 "django.contrib.sessions.middleware.SessionMiddleware",
145 "django.middleware.csrf.CsrfViewMiddleware",
146 "django.contrib.auth.middleware.AuthenticationMiddleware",
147 "django.contrib.messages.middleware.MessageMiddleware",
148 "core.middleware.GlobalRequestMiddleware",
Tony Mack7130ac32013-03-22 21:58:00 -0400149 # Uncomment the next line for simple clickjacking protection:
150 # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
151)
152
Zack Williams045b63d2019-01-22 16:30:57 -0700153ROOT_URLCONF = "xos.urls"
Tony Mack7130ac32013-03-22 21:58:00 -0400154
155# Python dotted path to the WSGI application used by Django's runserver.
Zack Williams045b63d2019-01-22 16:30:57 -0700156WSGI_APPLICATION = "xos.wsgi.application"
Srikanth Vavilapalli40fd9862015-10-27 00:15:58 -0400157# Default: 'csrftoken'
Zack Williams045b63d2019-01-22 16:30:57 -0700158CSRF_COOKIE_NAME = "xoscsrftoken"
Srikanth Vavilapalli40fd9862015-10-27 00:15:58 -0400159# Default: 'django_language'
Zack Williams045b63d2019-01-22 16:30:57 -0700160LANGUAGE_COOKIE_NAME = "xos_django_language"
Srikanth Vavilapalli40fd9862015-10-27 00:15:58 -0400161# Default: 'sessionid'
Zack Williams045b63d2019-01-22 16:30:57 -0700162SESSION_COOKIE_NAME = "xossessionid"
Tony Mack7130ac32013-03-22 21:58:00 -0400163
164TEMPLATE_DIRS = (
165 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
166 # Always use forward slashes, even on Windows.
167 # Don't forget to use absolute paths, not relative paths.
Scott Bakerb7a573d2015-02-04 16:48:01 -0800168 XOS_DIR + "/templates",
Zack Williams045b63d2019-01-22 16:30:57 -0700169 # XOS_DIR + "/core/xoslib/templates",
Tony Mack7130ac32013-03-22 21:58:00 -0400170)
171
172INSTALLED_APPS = (
Zack Williams045b63d2019-01-22 16:30:57 -0700173 "django.contrib.auth",
174 "django.contrib.contenttypes",
175 "django.contrib.sessions",
176 "django.contrib.messages",
177 "django_extensions",
178 "core",
Tony Mack7130ac32013-03-22 21:58:00 -0400179)
180
Scott Baker9c6191e2016-06-01 23:32:25 -0700181# add services that were configured by xosbuilder to INSTALLED_APPS
Scott Baker4310c382016-06-07 17:54:43 -0700182if os.path.exists("/opt/xos/xos/xosbuilder_app_list"):
183 for line in file("/opt/xos/xos/xosbuilder_app_list").readlines():
Scott Baker9c6191e2016-06-01 23:32:25 -0700184 line = line.strip()
185 if line:
186 INSTALLED_APPS = list(INSTALLED_APPS) + [line]
187
Matteo Scandolo57fdb4b2019-02-06 18:27:56 -0800188# add services that needs to be migrated to INSTALLED_APPS
189# this is used by xos-migrate.py
190if "INSTALLED_APPS" in os.environ:
191 apps = os.environ["INSTALLED_APPS"].split(',')
192 for app in apps:
193 INSTALLED_APPS = list(INSTALLED_APPS) + [app]
194
Tony Mack7130ac32013-03-22 21:58:00 -0400195# A sample logging configuration. The only tangible logging
196# performed by this configuration is to send an email to
197# the site admins on every HTTP 500 error when DEBUG=False.
198# See http://docs.djangoproject.com/en/dev/topics/logging for
199# more details on how to customize your logging configuration.
Matteo Scandolo57fdb4b2019-02-06 18:27:56 -0800200LOG_FILE = "/var/log/django_debug.log"
201if "LOG_FILE" in os.environ:
202 LOG_FILE = os.environ["LOG_FILE"]
Tony Mack7130ac32013-03-22 21:58:00 -0400203LOGGING = {
Zack Williams045b63d2019-01-22 16:30:57 -0700204 "version": 1,
205 "disable_existing_loggers": False,
206 "filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
207 "handlers": {
208 "file": {
209 "level": "DEBUG",
210 "class": "logging.FileHandler",
Matteo Scandolo57fdb4b2019-02-06 18:27:56 -0800211 "filename": LOG_FILE,
Zack Williams96379722016-02-24 09:59:37 -0700212 },
Zack Williams045b63d2019-01-22 16:30:57 -0700213 "mail_admins": {
214 "level": "ERROR",
215 "filters": ["require_debug_false"],
216 "class": "django.utils.log.AdminEmailHandler",
Zack Williams96379722016-02-24 09:59:37 -0700217 },
Tony Mack7130ac32013-03-22 21:58:00 -0400218 },
Zack Williams045b63d2019-01-22 16:30:57 -0700219 "loggers": {
220 "django": {"handlers": ["file"], "level": "DEBUG", "propagate": True},
221 "django.request": {
222 "handlers": ["mail_admins"],
223 "level": "ERROR",
224 "propagate": True,
Zack Williams96379722016-02-24 09:59:37 -0700225 },
Zack Williams045b63d2019-01-22 16:30:57 -0700226 "django.db.backends": {"level": "WARNING"},
227 },
Tony Mack7130ac32013-03-22 21:58:00 -0400228}
Scott Bakerc40941b2014-04-25 12:20:47 -0700229
Matteo Scandolo6bc017c2017-05-25 18:37:42 -0700230XOS_BRANDING_NAME = "OpenCloud"
231XOS_BRANDING_CSS = None
232XOS_BRANDING_ICON = "/static/logo.png"
233XOS_BRANDING_FAVICON = "/static/favicon.png"
234XOS_BRANDING_BG = "/static/bg.png"
Scott Baker0e439b12015-03-09 11:11:09 -0700235
Matteo Scandolo6bc017c2017-05-25 18:37:42 -0700236DISABLE_MINIDASHBOARD = False
Zack Williams045b63d2019-01-22 16:30:57 -0700237ENCRYPTED_FIELDS_KEYDIR = XOS_DIR + "/private_keys"
238ENCRYPTED_FIELD_MODE = "ENCRYPT"
Scott Baker370cdd52014-09-12 12:38:34 -0700239
Matteo Scandolo6bc017c2017-05-25 18:37:42 -0700240STATISTICS_DRIVER = "statistics_driver"
Scott Baker169c7232015-01-03 16:51:01 -0800241
Scott Baker0e439b12015-03-09 11:11:09 -0700242# prevents warnings on django 1.7
Zack Williams045b63d2019-01-22 16:30:57 -0700243TEST_RUNNER = "django.test.runner.DiscoverRunner"
Zack Williams2c336d82016-06-29 09:25:49 -0700244
245# API key for Google Maps, created by zdw on 2016-06-29. Testing only, not for production
Zack Williams045b63d2019-01-22 16:30:57 -0700246GEOPOSITION_GOOGLE_MAPS_API_KEY = "AIzaSyBWAHP9mvLqWLRkVqK8o5wMskaIe9w7DaM"