blob: 644cba9ac97aba18cc87a6280ec7a7da3ef16d1b [file] [log] [blame]
lombardofr3218b2b2018-10-29 13:41:08 +01001#
2# Copyright 2018 EveryUP Srl
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
lombardoffb37bca2018-05-03 16:20:04 +020016
17import os
Benjamin Diaz65f0dc42019-05-24 17:54:48 -030018from sqlalchemy.engine.url import make_url
lombardoffb37bca2018-05-03 16:20:04 +020019
20# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
21BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22
23
24# Quick-start development settings - unsuitable for production
25# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
26
27# SECURITY WARNING: keep the secret key used in production secret!
28SECRET_KEY = 'o5+o2jv(3-dqr(&ia#-@79cgr%xi*s+6xjws^8cxp211ge#buf'
lombardofrc89a4a02018-09-02 16:15:25 +020029if os.getenv('DJANGO_ENV') == 'prod':
30 DEBUG = False
31else:
32 DEBUG = True
lombardofr3fcf21a2019-03-11 10:26:08 +010033
lombardofrc89a4a02018-09-02 16:15:25 +020034ALLOWED_HOSTS = ['*']
lombardoffb37bca2018-05-03 16:20:04 +020035
lombardofr099364f2018-06-12 11:21:02 +020036AUTH_USER_MODEL = "authosm.OsmUser"
lombardoffb37bca2018-05-03 16:20:04 +020037
lombardof33848292018-05-08 10:12:14 +020038SITE_NAME = "Open Source MANO"
39SHORT_SITE_NAME = "OSM"
lombardoffb37bca2018-05-03 16:20:04 +020040
41LOGIN_URL = '/auth/'
42LOGOUT_URL = '/auth/'
43
44VERSION = "0.0.1"
45
46
47# Application definition
48INSTALLED_APPS = [
49 'django.contrib.admin',
50 'django.contrib.auth',
51 'django.contrib.contenttypes',
52 'django.contrib.messages',
53 'django.contrib.staticfiles',
lombardofr07930222018-06-19 16:59:45 +020054 'django.contrib.sessions',
lombardofr099364f2018-06-12 11:21:02 +020055 'authosm',
lombardoffb37bca2018-05-03 16:20:04 +020056 'projecthandler',
lombardofre1ed7b22018-12-19 17:27:24 +010057 'packagehandler',
lombardofr3218b2b2018-10-29 13:41:08 +010058 'descriptorhandler',
lombardoffb37bca2018-05-03 16:20:04 +020059 'vimhandler',
lombardofr3fcf21a2019-03-11 10:26:08 +010060 'wimhandler',
lombardofa03da5e2018-06-02 18:36:44 +020061 'instancehandler',
lombardofr099364f2018-06-12 11:21:02 +020062 'sdnctrlhandler',
lombardofrc3051ef2019-01-16 10:59:18 +010063 'userhandler',
lombardofr8da23132019-06-02 17:18:48 +020064 'rolehandler',
lombardofrc3051ef2019-01-16 10:59:18 +010065 'netslicehandler'
lombardofr099364f2018-06-12 11:21:02 +020066
lombardoffb37bca2018-05-03 16:20:04 +020067]
68
69MIDDLEWARE_CLASSES = [
70 'django.middleware.security.SecurityMiddleware',
71 'django.contrib.sessions.middleware.SessionMiddleware',
lombardofr99f922f2018-07-17 17:27:36 +020072 'projecthandler.middleware.OsmProjectMiddleware',
lombardoffb37bca2018-05-03 16:20:04 +020073 'django.middleware.common.CommonMiddleware',
74 'django.middleware.csrf.CsrfViewMiddleware',
75 'django.contrib.auth.middleware.AuthenticationMiddleware',
76 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
77 'django.contrib.messages.middleware.MessageMiddleware',
78 'django.middleware.clickjacking.XFrameOptionsMiddleware',
79
lombardofr99f922f2018-07-17 17:27:36 +020080
lombardoffb37bca2018-05-03 16:20:04 +020081]
82
lombardofr07930222018-06-19 16:59:45 +020083SESSION_ENGINE ='django.contrib.sessions.backends.db'
lombardoffb37bca2018-05-03 16:20:04 +020084SESSION_COOKIE_AGE = 3500 #25 min
85SESSION_EXPIRE_AT_BROWSER_CLOSE = True
86SESSION_SAVE_EVERY_REQUEST = True
87
88ROOT_URLCONF = 'sf_t3d.urls'
89
90TEMPLATES = [
91 {
92 'BACKEND': 'django.template.backends.django.DjangoTemplates',
93 'DIRS': [
94 os.path.join(BASE_DIR, 'template'),
95 os.path.join(BASE_DIR, 'projecthandler', 'template'),
96 os.path.join(BASE_DIR, 'projecthandler', 'template', 'download'),
97 os.path.join(BASE_DIR, 'projecthandler', 'template', 'project'),
lombardofre1ed7b22018-12-19 17:27:24 +010098 os.path.join(BASE_DIR, 'packagehandler', 'template'),
lombardofr3218b2b2018-10-29 13:41:08 +010099 os.path.join(BASE_DIR, 'descriptorhandler', 'template'),
lombardoffb37bca2018-05-03 16:20:04 +0200100 os.path.join(BASE_DIR, 'vimhandler', 'template'),
lombardofr3fcf21a2019-03-11 10:26:08 +0100101 os.path.join(BASE_DIR, 'wimhandler', 'template'),
lombardoffb37bca2018-05-03 16:20:04 +0200102 os.path.join(BASE_DIR, 'instancehandler', 'template'),
lombardofa03da5e2018-06-02 18:36:44 +0200103 os.path.join(BASE_DIR, 'sdnctrlhandler', 'template'),
lombardofr10b52d12018-07-17 23:42:28 +0200104 os.path.join(BASE_DIR, 'userhandler', 'templates'),
lombardofrc3051ef2019-01-16 10:59:18 +0100105 os.path.join(BASE_DIR, 'netslicehandler', 'template'),
lombardoffb37bca2018-05-03 16:20:04 +0200106 ],
107 'APP_DIRS': True,
108 'OPTIONS': {
109 'context_processors': [
110 'django.template.context_processors.debug',
111 'django.template.context_processors.request',
112 'django.contrib.auth.context_processors.auth',
113 'django.contrib.messages.context_processors.messages',
114 'sf_t3d.context_processor.conf_constants',
115 ],
116 'libraries':{
117 'get': 'sf_t3d.templatetags.get',
lombardof74ed51a2018-05-11 01:07:01 +0200118 'date_tag': 'sf_t3d.templatetags.datetag',
lombardoffb37bca2018-05-03 16:20:04 +0200119 }
120 },
121 },
122]
123
124WSGI_APPLICATION = 'sf_t3d.wsgi.application'
125
126
127# Database
128# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
129
Benjamin Diaz65f0dc42019-05-24 17:54:48 -0300130sql_uri = make_url(os.getenv('OSMUI_SQL_DATABASE_URI', 'sqlite:///db.sqlite3'))
131if 'sqlite' in sql_uri.drivername:
132 DATABASES = {
133 'default': {
134 'ENGINE': 'django.db.backends.sqlite3',
135 'NAME': os.path.join(BASE_DIR, sql_uri.database if sql_uri.database else 'db.sqlite3'),
136 }
lombardoffb37bca2018-05-03 16:20:04 +0200137 }
Benjamin Diaz65f0dc42019-05-24 17:54:48 -0300138else:
139 DATABASES = {
140 'default': {
141 'ENGINE': 'django.db.backends.mysql',
142 'NAME': sql_uri.database if sql_uri.database else 'lwui',
143 'USER': sql_uri.username,
144 'PASSWORD': sql_uri.password,
145 'HOST': sql_uri.host,
146 'PORT': sql_uri.port,
147 }
148 }
149
lombardoffb37bca2018-05-03 16:20:04 +0200150
lombardofr099364f2018-06-12 11:21:02 +0200151AUTHENTICATION_BACKENDS = ['authosm.backend.OsmBackend']
152
lombardoffb37bca2018-05-03 16:20:04 +0200153
154# Password validation
155# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
156
157AUTH_PASSWORD_VALIDATORS = [
158 {
159 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
160 },
161 {
162 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
163 },
164 {
165 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
166 },
167 {
168 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
169 },
170]
171
172
173# Internationalization
174# https://docs.djangoproject.com/en/1.9/topics/i18n/
175
176LANGUAGE_CODE = 'en-us'
177
178TIME_ZONE = 'UTC'
179
180USE_I18N = True
181
182USE_L10N = True
183
184USE_TZ = True
185
186
187# Static files (CSS, JavaScript, Images)
188# https://docs.djangoproject.com/en/1.9/howto/static-files/
189
190STATIC_URL = '/static/'
lombardofrc89a4a02018-09-02 16:15:25 +0200191if DEBUG:
192 STATICFILES_FINDERS = (
193 'django.contrib.staticfiles.finders.FileSystemFinder',
194 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
195 'django.contrib.staticfiles.finders.DefaultStorageFinder'
196 )
197 STATICFILES_DIRS = (
198 # Put strings here, like "/home/html/static" or "C:/www/django/static".
199 # Always use forward slashes, even on Windows.
200 # Don't forget to use absolute paths, not relative paths.
201 os.path.join(BASE_DIR, "static"),
202 )
203else:
204 STATIC_ROOT = os.path.join(BASE_DIR, "static/")
lombardoffb37bca2018-05-03 16:20:04 +0200205
206LOCALE_PATHS = (
207 os.path.join(BASE_DIR, 'locale'),
lombardofrc89a4a02018-09-02 16:15:25 +0200208)