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.
18 from sqlalchemy
.engine
.url
import make_url
20 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
21 BASE_DIR
= os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
24 # Quick-start development settings - unsuitable for production
25 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
27 # SECURITY WARNING: keep the secret key used in production secret!
28 SECRET_KEY
= 'o5+o2jv(3-dqr(&ia#-@79cgr%xi*s+6xjws^8cxp211ge#buf'
29 if os
.getenv('DJANGO_ENV') == 'prod':
36 AUTH_USER_MODEL
= "authosm.OsmUser"
38 SITE_NAME
= "Open Source MANO"
39 SHORT_SITE_NAME
= "OSM"
47 # Application definition
49 'django.contrib.admin',
50 'django.contrib.auth',
51 'django.contrib.contenttypes',
52 'django.contrib.messages',
53 'django.contrib.staticfiles',
54 'django.contrib.sessions',
69 MIDDLEWARE_CLASSES
= [
70 'django.middleware.security.SecurityMiddleware',
71 'django.contrib.sessions.middleware.SessionMiddleware',
72 'projecthandler.middleware.OsmProjectMiddleware',
73 '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',
83 SESSION_ENGINE
='django.contrib.sessions.backends.db'
84 SESSION_COOKIE_AGE
= 3500 #25 min
85 SESSION_EXPIRE_AT_BROWSER_CLOSE
= True
86 SESSION_SAVE_EVERY_REQUEST
= True
88 ROOT_URLCONF
= 'sf_t3d.urls'
92 'BACKEND': 'django.template.backends.django.DjangoTemplates',
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'),
98 os
.path
.join(BASE_DIR
, 'packagehandler', 'template'),
99 os
.path
.join(BASE_DIR
, 'descriptorhandler', 'template'),
100 os
.path
.join(BASE_DIR
, 'vimhandler', 'template'),
101 os
.path
.join(BASE_DIR
, 'wimhandler', 'template'),
102 os
.path
.join(BASE_DIR
, 'instancehandler', 'template'),
103 os
.path
.join(BASE_DIR
, 'sdnctrlhandler', 'template'),
104 os
.path
.join(BASE_DIR
, 'userhandler', 'templates'),
105 os
.path
.join(BASE_DIR
, 'netslicehandler', 'template'),
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',
117 'get': 'sf_t3d.templatetags.get',
118 'date_tag': 'sf_t3d.templatetags.datetag',
124 WSGI_APPLICATION
= 'sf_t3d.wsgi.application'
128 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
130 sql_uri
= make_url(os
.getenv('OSMUI_SQL_DATABASE_URI', 'sqlite:///db.sqlite3'))
131 if 'sqlite' in sql_uri
.drivername
:
134 'ENGINE': 'django.db.backends.sqlite3',
135 'NAME': os
.path
.join(BASE_DIR
, sql_uri
.database
if sql_uri
.database
else 'db.sqlite3'),
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
,
151 AUTHENTICATION_BACKENDS
= ['authosm.backend.OsmBackend']
154 # Password validation
155 # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
157 AUTH_PASSWORD_VALIDATORS
= [
159 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
162 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
165 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
168 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
173 # Internationalization
174 # https://docs.djangoproject.com/en/1.9/topics/i18n/
176 LANGUAGE_CODE
= 'en-us'
187 # Static files (CSS, JavaScript, Images)
188 # https://docs.djangoproject.com/en/1.9/howto/static-files/
190 STATIC_URL
= '/static/'
192 STATICFILES_FINDERS
= (
193 'django.contrib.staticfiles.finders.FileSystemFinder',
194 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
195 'django.contrib.staticfiles.finders.DefaultStorageFinder'
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"),
204 STATIC_ROOT
= os
.path
.join(BASE_DIR
, "static/")
207 os
.path
.join(BASE_DIR
, 'locale'),