2 # Copyright 2018 EveryUP Srl
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
20 from sqlalchemy
.engine
.url
import make_url
22 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
23 BASE_DIR
= os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
26 # Quick-start development settings - unsuitable for production
27 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
29 # SECURITY WARNING: keep the secret key used in production secret!
30 SECRET_KEY
= 'o5+o2jv(3-dqr(&ia#-@79cgr%xi*s+6xjws^8cxp211ge#buf'
31 if os
.getenv('DJANGO_ENV') == 'prod':
38 AUTH_USER_MODEL
= "authosm.OsmUser"
40 SITE_NAME
= "Open Source MANO"
41 SHORT_SITE_NAME
= "OSM"
49 # Application definition
51 'django.contrib.admin',
52 'django.contrib.auth',
53 'django.contrib.contenttypes',
54 'django.contrib.messages',
55 'django.contrib.staticfiles',
56 'django.contrib.sessions',
74 MIDDLEWARE_CLASSES
= [
75 'django.middleware.security.SecurityMiddleware',
76 'django.contrib.sessions.middleware.SessionMiddleware',
77 'projecthandler.middleware.OsmProjectMiddleware',
78 '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',
88 SESSION_ENGINE
='django.contrib.sessions.backends.db'
89 SESSION_COOKIE_AGE
= 3500 #25 min
90 SESSION_EXPIRE_AT_BROWSER_CLOSE
= True
91 SESSION_SAVE_EVERY_REQUEST
= True
93 ROOT_URLCONF
= 'sf_t3d.urls'
97 'BACKEND': 'django.template.backends.django.DjangoTemplates',
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'),
103 os
.path
.join(BASE_DIR
, 'packagehandler', 'template'),
104 os
.path
.join(BASE_DIR
, 'descriptorhandler', 'template'),
105 os
.path
.join(BASE_DIR
, 'vimhandler', 'template'),
106 os
.path
.join(BASE_DIR
, 'wimhandler', 'template'),
107 os
.path
.join(BASE_DIR
, 'instancehandler', 'template'),
108 os
.path
.join(BASE_DIR
, 'sdnctrlhandler', 'template'),
109 os
.path
.join(BASE_DIR
, 'userhandler', 'templates'),
110 os
.path
.join(BASE_DIR
, 'netslicehandler', 'template'),
111 os
.path
.join(BASE_DIR
, 'k8sclusterhandler', 'template'),
112 os
.path
.join(BASE_DIR
, 'k8srepohandler', 'template'),
113 os
.path
.join(BASE_DIR
, 'osmrepohandler', 'template'),
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',
125 'get': 'sf_t3d.templatetags.get',
126 'date_tag': 'sf_t3d.templatetags.datetag',
132 WSGI_APPLICATION
= 'sf_t3d.wsgi.application'
136 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
138 sql_uri
= make_url(os
.getenv('OSMUI_SQL_DATABASE_URI', 'sqlite:///db.sqlite3'))
139 if 'sqlite' in sql_uri
.drivername
:
142 'ENGINE': 'django.db.backends.sqlite3',
143 'NAME': os
.path
.join(BASE_DIR
, sql_uri
.database
if sql_uri
.database
else 'db.sqlite3'),
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
,
159 AUTHENTICATION_BACKENDS
= ['authosm.backend.OsmBackend']
162 # Password validation
163 # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
165 AUTH_PASSWORD_VALIDATORS
= [
167 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
170 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
173 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
176 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
181 # Internationalization
182 # https://docs.djangoproject.com/en/1.9/topics/i18n/
184 LANGUAGE_CODE
= 'en-us'
195 # Static files (CSS, JavaScript, Images)
196 # https://docs.djangoproject.com/en/1.9/howto/static-files/
198 STATIC_URL
= '/static/'
200 STATICFILES_FINDERS
= (
201 'django.contrib.staticfiles.finders.FileSystemFinder',
202 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
203 'django.contrib.staticfiles.finders.DefaultStorageFinder'
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"),
212 STATIC_ROOT
= os
.path
.join(BASE_DIR
, "static/")
215 os
.path
.join(BASE_DIR
, 'locale'),
220 'disable_existing_loggers': False,
223 'format': '[django] %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
229 'class': 'logging.StreamHandler',
230 'stream': sys
.stdout
,
231 'formatter': 'verbose'
236 'handlers': ['console'],