blob: 560d05fc27fd25ff296a20b3b2fbb445e521db64 [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 Diazc38fffb2019-07-24 15:57:38 -030018import sys
19
Benjamin Diaz65f0dc42019-05-24 17:54:48 -030020from sqlalchemy.engine.url import make_url
lombardoffb37bca2018-05-03 16:20:04 +020021
22# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
23BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
24
25
26# Quick-start development settings - unsuitable for production
27# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
28
29# SECURITY WARNING: keep the secret key used in production secret!
30SECRET_KEY = 'o5+o2jv(3-dqr(&ia#-@79cgr%xi*s+6xjws^8cxp211ge#buf'
lombardofrc89a4a02018-09-02 16:15:25 +020031if os.getenv('DJANGO_ENV') == 'prod':
32 DEBUG = False
33else:
34 DEBUG = True
lombardofr3fcf21a2019-03-11 10:26:08 +010035
lombardofrc89a4a02018-09-02 16:15:25 +020036ALLOWED_HOSTS = ['*']
lombardoffb37bca2018-05-03 16:20:04 +020037
lombardofr099364f2018-06-12 11:21:02 +020038AUTH_USER_MODEL = "authosm.OsmUser"
lombardoffb37bca2018-05-03 16:20:04 +020039
lombardof33848292018-05-08 10:12:14 +020040SITE_NAME = "Open Source MANO"
41SHORT_SITE_NAME = "OSM"
lombardoffb37bca2018-05-03 16:20:04 +020042
43LOGIN_URL = '/auth/'
44LOGOUT_URL = '/auth/'
45
46VERSION = "0.0.1"
47
48
49# Application definition
50INSTALLED_APPS = [
51 'django.contrib.admin',
52 'django.contrib.auth',
53 'django.contrib.contenttypes',
54 'django.contrib.messages',
55 'django.contrib.staticfiles',
lombardofr07930222018-06-19 16:59:45 +020056 'django.contrib.sessions',
lombardofr099364f2018-06-12 11:21:02 +020057 'authosm',
lombardoffb37bca2018-05-03 16:20:04 +020058 'projecthandler',
lombardofre1ed7b22018-12-19 17:27:24 +010059 'packagehandler',
lombardofr3218b2b2018-10-29 13:41:08 +010060 'descriptorhandler',
lombardoffb37bca2018-05-03 16:20:04 +020061 'vimhandler',
lombardofr3fcf21a2019-03-11 10:26:08 +010062 'wimhandler',
lombardofa03da5e2018-06-02 18:36:44 +020063 'instancehandler',
lombardofr099364f2018-06-12 11:21:02 +020064 'sdnctrlhandler',
lombardofrc3051ef2019-01-16 10:59:18 +010065 'userhandler',
lombardofr8da23132019-06-02 17:18:48 +020066 'rolehandler',
lombardofr3c7234a2019-12-03 11:23:17 +010067 'netslicehandler',
68 'k8sclusterhandler',
meliane59fb022020-05-06 09:53:27 +000069 'k8srepohandler',
70 'osmrepohandler'
lombardofr099364f2018-06-12 11:21:02 +020071
lombardoffb37bca2018-05-03 16:20:04 +020072]
73
74MIDDLEWARE_CLASSES = [
75 'django.middleware.security.SecurityMiddleware',
76 'django.contrib.sessions.middleware.SessionMiddleware',
lombardofr99f922f2018-07-17 17:27:36 +020077 'projecthandler.middleware.OsmProjectMiddleware',
lombardoffb37bca2018-05-03 16:20:04 +020078 'django.middleware.common.CommonMiddleware',
79 'django.middleware.csrf.CsrfViewMiddleware',
80 'django.contrib.auth.middleware.AuthenticationMiddleware',
81 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
82 'django.contrib.messages.middleware.MessageMiddleware',
83 'django.middleware.clickjacking.XFrameOptionsMiddleware',
84
lombardofr99f922f2018-07-17 17:27:36 +020085
lombardoffb37bca2018-05-03 16:20:04 +020086]
87
lombardofr07930222018-06-19 16:59:45 +020088SESSION_ENGINE ='django.contrib.sessions.backends.db'
lombardoffb37bca2018-05-03 16:20:04 +020089SESSION_COOKIE_AGE = 3500 #25 min
90SESSION_EXPIRE_AT_BROWSER_CLOSE = True
91SESSION_SAVE_EVERY_REQUEST = True
92
93ROOT_URLCONF = 'sf_t3d.urls'
94
95TEMPLATES = [
96 {
97 'BACKEND': 'django.template.backends.django.DjangoTemplates',
98 'DIRS': [
99 os.path.join(BASE_DIR, 'template'),
100 os.path.join(BASE_DIR, 'projecthandler', 'template'),
101 os.path.join(BASE_DIR, 'projecthandler', 'template', 'download'),
102 os.path.join(BASE_DIR, 'projecthandler', 'template', 'project'),
lombardofre1ed7b22018-12-19 17:27:24 +0100103 os.path.join(BASE_DIR, 'packagehandler', 'template'),
lombardofr3218b2b2018-10-29 13:41:08 +0100104 os.path.join(BASE_DIR, 'descriptorhandler', 'template'),
lombardoffb37bca2018-05-03 16:20:04 +0200105 os.path.join(BASE_DIR, 'vimhandler', 'template'),
lombardofr3fcf21a2019-03-11 10:26:08 +0100106 os.path.join(BASE_DIR, 'wimhandler', 'template'),
lombardoffb37bca2018-05-03 16:20:04 +0200107 os.path.join(BASE_DIR, 'instancehandler', 'template'),
lombardofa03da5e2018-06-02 18:36:44 +0200108 os.path.join(BASE_DIR, 'sdnctrlhandler', 'template'),
lombardofr10b52d12018-07-17 23:42:28 +0200109 os.path.join(BASE_DIR, 'userhandler', 'templates'),
lombardofrc3051ef2019-01-16 10:59:18 +0100110 os.path.join(BASE_DIR, 'netslicehandler', 'template'),
lombardofr3c7234a2019-12-03 11:23:17 +0100111 os.path.join(BASE_DIR, 'k8sclusterhandler', 'template'),
112 os.path.join(BASE_DIR, 'k8srepohandler', 'template'),
meliane59fb022020-05-06 09:53:27 +0000113 os.path.join(BASE_DIR, 'osmrepohandler', 'template'),
lombardoffb37bca2018-05-03 16:20:04 +0200114 ],
115 'APP_DIRS': True,
116 'OPTIONS': {
117 'context_processors': [
118 'django.template.context_processors.debug',
119 'django.template.context_processors.request',
120 'django.contrib.auth.context_processors.auth',
121 'django.contrib.messages.context_processors.messages',
122 'sf_t3d.context_processor.conf_constants',
123 ],
124 'libraries':{
125 'get': 'sf_t3d.templatetags.get',
lombardof74ed51a2018-05-11 01:07:01 +0200126 'date_tag': 'sf_t3d.templatetags.datetag',
lombardoffb37bca2018-05-03 16:20:04 +0200127 }
128 },
129 },
130]
131
132WSGI_APPLICATION = 'sf_t3d.wsgi.application'
133
134
135# Database
136# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
137
Benjamin Diaz65f0dc42019-05-24 17:54:48 -0300138sql_uri = make_url(os.getenv('OSMUI_SQL_DATABASE_URI', 'sqlite:///db.sqlite3'))
139if 'sqlite' in sql_uri.drivername:
140 DATABASES = {
141 'default': {
142 'ENGINE': 'django.db.backends.sqlite3',
143 'NAME': os.path.join(BASE_DIR, sql_uri.database if sql_uri.database else 'db.sqlite3'),
144 }
lombardoffb37bca2018-05-03 16:20:04 +0200145 }
Benjamin Diaz65f0dc42019-05-24 17:54:48 -0300146else:
147 DATABASES = {
148 'default': {
149 'ENGINE': 'django.db.backends.mysql',
150 'NAME': sql_uri.database if sql_uri.database else 'lwui',
151 'USER': sql_uri.username,
152 'PASSWORD': sql_uri.password,
153 'HOST': sql_uri.host,
154 'PORT': sql_uri.port,
155 }
156 }
157
lombardoffb37bca2018-05-03 16:20:04 +0200158
lombardofr099364f2018-06-12 11:21:02 +0200159AUTHENTICATION_BACKENDS = ['authosm.backend.OsmBackend']
160
lombardoffb37bca2018-05-03 16:20:04 +0200161
162# Password validation
163# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
164
165AUTH_PASSWORD_VALIDATORS = [
166 {
167 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
168 },
169 {
170 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
171 },
172 {
173 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
174 },
175 {
176 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
177 },
178]
179
180
181# Internationalization
182# https://docs.djangoproject.com/en/1.9/topics/i18n/
183
184LANGUAGE_CODE = 'en-us'
185
186TIME_ZONE = 'UTC'
187
188USE_I18N = True
189
190USE_L10N = True
191
192USE_TZ = True
193
194
195# Static files (CSS, JavaScript, Images)
196# https://docs.djangoproject.com/en/1.9/howto/static-files/
197
198STATIC_URL = '/static/'
lombardofrc89a4a02018-09-02 16:15:25 +0200199if DEBUG:
200 STATICFILES_FINDERS = (
201 'django.contrib.staticfiles.finders.FileSystemFinder',
202 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
203 'django.contrib.staticfiles.finders.DefaultStorageFinder'
204 )
205 STATICFILES_DIRS = (
206 # Put strings here, like "/home/html/static" or "C:/www/django/static".
207 # Always use forward slashes, even on Windows.
208 # Don't forget to use absolute paths, not relative paths.
209 os.path.join(BASE_DIR, "static"),
210 )
211else:
212 STATIC_ROOT = os.path.join(BASE_DIR, "static/")
lombardoffb37bca2018-05-03 16:20:04 +0200213
214LOCALE_PATHS = (
215 os.path.join(BASE_DIR, 'locale'),
lombardofrc89a4a02018-09-02 16:15:25 +0200216)
Benjamin Diazc38fffb2019-07-24 15:57:38 -0300217
218LOGGING = {
219 'version': 1,
220 'disable_existing_loggers': False,
221 'formatters': {
222 'verbose': {
223 'format': '[django] %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
224 }
225 },
226 'handlers': {
227 'console': {
228 'level': 'DEBUG',
229 'class': 'logging.StreamHandler',
230 'stream': sys.stdout,
231 'formatter': 'verbose'
232 },
233 },
234 'loggers': {
235 'django': {
236 'handlers': ['console'],
237 'level': 'DEBUG',
238 'propagate': True,
239 },
240 },
241}