k8sClusters; k8sRepos
[osm/LW-UI.git] / sf_t3d / settings.py
1 #
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 #
16
17 import os
18 import sys
19
20 from sqlalchemy.engine.url import make_url
21
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__)))
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!
30 SECRET_KEY = 'o5+o2jv(3-dqr(&ia#-@79cgr%xi*s+6xjws^8cxp211ge#buf'
31 if os.getenv('DJANGO_ENV') == 'prod':
32 DEBUG = False
33 else:
34 DEBUG = True
35
36 ALLOWED_HOSTS = ['*']
37
38 AUTH_USER_MODEL = "authosm.OsmUser"
39
40 SITE_NAME = "Open Source MANO"
41 SHORT_SITE_NAME = "OSM"
42
43 LOGIN_URL = '/auth/'
44 LOGOUT_URL = '/auth/'
45
46 VERSION = "0.0.1"
47
48
49 # Application definition
50 INSTALLED_APPS = [
51 'django.contrib.admin',
52 'django.contrib.auth',
53 'django.contrib.contenttypes',
54 'django.contrib.messages',
55 'django.contrib.staticfiles',
56 'django.contrib.sessions',
57 'authosm',
58 'projecthandler',
59 'packagehandler',
60 'descriptorhandler',
61 'vimhandler',
62 'wimhandler',
63 'instancehandler',
64 'sdnctrlhandler',
65 'userhandler',
66 'rolehandler',
67 'netslicehandler',
68 'k8sclusterhandler',
69 'k8srepohandler'
70
71 ]
72
73 MIDDLEWARE_CLASSES = [
74 'django.middleware.security.SecurityMiddleware',
75 'django.contrib.sessions.middleware.SessionMiddleware',
76 'projecthandler.middleware.OsmProjectMiddleware',
77 'django.middleware.common.CommonMiddleware',
78 'django.middleware.csrf.CsrfViewMiddleware',
79 'django.contrib.auth.middleware.AuthenticationMiddleware',
80 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
81 'django.contrib.messages.middleware.MessageMiddleware',
82 'django.middleware.clickjacking.XFrameOptionsMiddleware',
83
84
85 ]
86
87 SESSION_ENGINE ='django.contrib.sessions.backends.db'
88 SESSION_COOKIE_AGE = 3500 #25 min
89 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
90 SESSION_SAVE_EVERY_REQUEST = True
91
92 ROOT_URLCONF = 'sf_t3d.urls'
93
94 TEMPLATES = [
95 {
96 'BACKEND': 'django.template.backends.django.DjangoTemplates',
97 'DIRS': [
98 os.path.join(BASE_DIR, 'template'),
99 os.path.join(BASE_DIR, 'projecthandler', 'template'),
100 os.path.join(BASE_DIR, 'projecthandler', 'template', 'download'),
101 os.path.join(BASE_DIR, 'projecthandler', 'template', 'project'),
102 os.path.join(BASE_DIR, 'packagehandler', 'template'),
103 os.path.join(BASE_DIR, 'descriptorhandler', 'template'),
104 os.path.join(BASE_DIR, 'vimhandler', 'template'),
105 os.path.join(BASE_DIR, 'wimhandler', 'template'),
106 os.path.join(BASE_DIR, 'instancehandler', 'template'),
107 os.path.join(BASE_DIR, 'sdnctrlhandler', 'template'),
108 os.path.join(BASE_DIR, 'userhandler', 'templates'),
109 os.path.join(BASE_DIR, 'netslicehandler', 'template'),
110 os.path.join(BASE_DIR, 'k8sclusterhandler', 'template'),
111 os.path.join(BASE_DIR, 'k8srepohandler', 'template'),
112 ],
113 'APP_DIRS': True,
114 'OPTIONS': {
115 'context_processors': [
116 'django.template.context_processors.debug',
117 'django.template.context_processors.request',
118 'django.contrib.auth.context_processors.auth',
119 'django.contrib.messages.context_processors.messages',
120 'sf_t3d.context_processor.conf_constants',
121 ],
122 'libraries':{
123 'get': 'sf_t3d.templatetags.get',
124 'date_tag': 'sf_t3d.templatetags.datetag',
125 }
126 },
127 },
128 ]
129
130 WSGI_APPLICATION = 'sf_t3d.wsgi.application'
131
132
133 # Database
134 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
135
136 sql_uri = make_url(os.getenv('OSMUI_SQL_DATABASE_URI', 'sqlite:///db.sqlite3'))
137 if 'sqlite' in sql_uri.drivername:
138 DATABASES = {
139 'default': {
140 'ENGINE': 'django.db.backends.sqlite3',
141 'NAME': os.path.join(BASE_DIR, sql_uri.database if sql_uri.database else 'db.sqlite3'),
142 }
143 }
144 else:
145 DATABASES = {
146 'default': {
147 'ENGINE': 'django.db.backends.mysql',
148 'NAME': sql_uri.database if sql_uri.database else 'lwui',
149 'USER': sql_uri.username,
150 'PASSWORD': sql_uri.password,
151 'HOST': sql_uri.host,
152 'PORT': sql_uri.port,
153 }
154 }
155
156
157 AUTHENTICATION_BACKENDS = ['authosm.backend.OsmBackend']
158
159
160 # Password validation
161 # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
162
163 AUTH_PASSWORD_VALIDATORS = [
164 {
165 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
166 },
167 {
168 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
169 },
170 {
171 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
172 },
173 {
174 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
175 },
176 ]
177
178
179 # Internationalization
180 # https://docs.djangoproject.com/en/1.9/topics/i18n/
181
182 LANGUAGE_CODE = 'en-us'
183
184 TIME_ZONE = 'UTC'
185
186 USE_I18N = True
187
188 USE_L10N = True
189
190 USE_TZ = True
191
192
193 # Static files (CSS, JavaScript, Images)
194 # https://docs.djangoproject.com/en/1.9/howto/static-files/
195
196 STATIC_URL = '/static/'
197 if DEBUG:
198 STATICFILES_FINDERS = (
199 'django.contrib.staticfiles.finders.FileSystemFinder',
200 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
201 'django.contrib.staticfiles.finders.DefaultStorageFinder'
202 )
203 STATICFILES_DIRS = (
204 # Put strings here, like "/home/html/static" or "C:/www/django/static".
205 # Always use forward slashes, even on Windows.
206 # Don't forget to use absolute paths, not relative paths.
207 os.path.join(BASE_DIR, "static"),
208 )
209 else:
210 STATIC_ROOT = os.path.join(BASE_DIR, "static/")
211
212 LOCALE_PATHS = (
213 os.path.join(BASE_DIR, 'locale'),
214 )
215
216 LOGGING = {
217 'version': 1,
218 'disable_existing_loggers': False,
219 'formatters': {
220 'verbose': {
221 'format': '[django] %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
222 }
223 },
224 'handlers': {
225 'console': {
226 'level': 'DEBUG',
227 'class': 'logging.StreamHandler',
228 'stream': sys.stdout,
229 'formatter': 'verbose'
230 },
231 },
232 'loggers': {
233 'django': {
234 'handlers': ['console'],
235 'level': 'DEBUG',
236 'propagate': True,
237 },
238 },
239 }