vvp -- VNF Validation Platform
[oom.git] / kubernetes / vvp / charts / vvp-cms-uwsgi / resources / config / cms / __init__.py
1 # Copyright © 2018 Amdocs, AT&T, Bell Canada
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from __future__ import absolute_import, unicode_literals
16 import os
17 from cms.envbool import envbool
18
19 from django import VERSION as DJANGO_VERSION
20 from django.utils.translation import ugettext_lazy as _
21 from boto.s3.connection import OrdinaryCallingFormat
22
23
24 ######################
25 # MEZZANINE SETTINGS #
26 ######################
27
28 # The following settings are already defined with default values in
29 # the ``defaults.py`` module within each of Mezzanine's apps, but are
30 # common enough to be put here, commented out, for conveniently
31 # overriding. Please consult the settings documentation for a full list
32 # of settings Mezzanine implements:
33 # http://mezzanine.jupo.org/docs/configuration.html#default-settings
34
35 # Controls the ordering and grouping of the admin menu.
36 #
37 # ADMIN_MENU_ORDER = (
38 #     ("Content", ("pages.Page", "blog.BlogPost",
39 #        "generic.ThreadedComment", (_("Media Library"), "media-library"),)),
40 #     ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
41 #     ("Users", ("auth.User", "auth.Group",)),
42 # )
43
44 # A three item sequence, each containing a sequence of template tags
45 # used to render the admin dashboard.
46 #
47 # DASHBOARD_TAGS = (
48 #     ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
49 #     ("comment_tags.recent_comments",),
50 #     ("mezzanine_tags.recent_actions",),
51 # )
52
53 # A sequence of templates used by the ``page_menu`` template tag. Each
54 # item in the sequence is a three item sequence, containing a unique ID
55 # for the template, a label for the template, and the template path.
56 # These templates are then available for selection when editing which
57 # menus a page should appear in. Note that if a menu template is used
58 # that doesn't appear in this setting, all pages will appear in it.
59
60 # PAGE_MENU_TEMPLATES = (
61 #     (1, _("Top navigation bar"), "pages/menus/dropdown.html"),
62 #     (2, _("Left-hand tree"), "pages/menus/tree.html"),
63 #     (3, _("Footer"), "pages/menus/footer.html"),
64 # )
65
66 # A sequence of fields that will be injected into Mezzanine's (or any
67 # library's) models. Each item in the sequence is a four item sequence.
68 # The first two items are the dotted path to the model and its field
69 # name to be added, and the dotted path to the field class to use for
70 # the field. The third and fourth items are a sequence of positional
71 # args and a dictionary of keyword args, to use when creating the
72 # field instance. When specifying the field class, the path
73 # ``django.models.db.`` can be omitted for regular Django model fields.
74 #
75 # EXTRA_MODEL_FIELDS = (
76 #     (
77 #         # Dotted path to field.
78 #         "mezzanine.blog.models.BlogPost.image",
79 #         # Dotted path to field class.
80 #         "somelib.fields.ImageField",
81 #         # Positional args for field class.
82 #         (_("Image"),),
83 #         # Keyword args for field class.
84 #         {"blank": True, "upload_to": "blog"},
85 #     ),
86 #     # Example of adding a field to *all* of Mezzanine's content types:
87 #     (
88 #         "mezzanine.pages.models.Page.another_field",
89 #         "IntegerField", # 'django.db.models.' is implied if path is omitted.
90 #         (_("Another name"),),
91 #         {"blank": True, "default": 1},
92 #     ),
93 # )
94
95 # Setting to turn on featured images for blog posts. Defaults to False.
96 #
97 # BLOG_USE_FEATURED_IMAGE = True
98
99 # If True, the django-modeltranslation will be added to the
100 # INSTALLED_APPS setting.
101 USE_MODELTRANSLATION = False
102
103
104 ########################
105 # MAIN DJANGO SETTINGS #
106 ########################
107
108 # Hosts/domain names that are valid for this site; required if DEBUG is False
109 # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
110 ALLOWED_HOSTS = ['*']
111
112 # Set UTC time zone:
113 TIME_ZONE = 'UTC'
114 USE_TZ = True
115
116 # Local time zone for this installation. Choices can be found here:
117 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
118 # although not all choices may be available on all operating systems.
119 # On Unix systems, a value of None will cause Django to use the same
120 # timezone as the operating system.
121 # If running in a Windows environment this must be set to the same as your
122 # system time zone.
123 TIME_ZONE = 'UTC'
124
125 # If you set this to True, Django will use timezone-aware datetimes.
126 USE_TZ = True
127
128 # Language code for this installation. All choices can be found here:
129 # http://www.i18nguy.com/unicode/language-identifiers.html
130 LANGUAGE_CODE = "en"
131
132 # Supported languages
133 LANGUAGES = (
134     ('en', _('English')),
135 )
136
137 ENVIRONMENT = os.environ['ENVIRONMENT']
138
139 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
140 SECRET_KEY = os.environ["SECRET_KEY"]
141
142 # A boolean that turns on/off debug mode. When set to ``True``, stack traces
143 # are displayed for error pages. Should always be set to ``False`` in
144 # production. Best set to ``True`` in local_settings.py
145 DEBUG = envbool('DJANGO_DEBUG_MODE', False)
146
147 # Note: Only SSL email backends are allowed
148 EMAIL_USE_SSL = True
149
150 # Whether a user's session cookie expires when the Web browser is closed.
151 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
152
153 SITE_ID = 1
154
155 # If you set this to False, Django will make some optimizations so as not
156 # to load the internationalization machinery.
157 USE_I18N = False
158
159 AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
160
161 # The numeric mode to set newly-uploaded files to. The value should be
162 # a mode you'd pass directly to os.chmod.
163 FILE_UPLOAD_PERMISSIONS = 0o644
164
165
166 #############
167 # DATABASES #
168 #############
169
170 DATABASES = {
171     'default': {
172         'ENGINE': 'django.db.backends.postgresql',
173         'NAME': os.environ['PGDATABASE'],
174         'USER': os.environ['PGUSER'],
175         'PASSWORD': os.environ['PGPASSWORD'],
176         'HOST': os.environ['PGHOST'],
177         'PORT': os.environ['PGPORT'],
178     }
179 }
180
181
182 #########
183 # PATHS #
184 #########
185
186 # Full filesystem path to the project.
187 PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
188 PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
189 PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
190
191 # Every cache key will get prefixed with this value - here we set it to
192 # the name of the directory the project is in to try and use something
193 # project specific.
194 CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
195
196 # Package/module name to import the root urlpatterns from for the project.
197 ROOT_URLCONF = 'cms.urls'
198
199 TEMPLATES = [
200     {
201         "BACKEND": "django.template.backends.django.DjangoTemplates",
202         "DIRS": [
203             os.path.join(PROJECT_ROOT, "templates")
204         ],
205         "APP_DIRS": True,
206         "OPTIONS": {
207             "context_processors": [
208                 "django.contrib.auth.context_processors.auth",
209                 "django.contrib.messages.context_processors.messages",
210                 "django.template.context_processors.debug",
211                 "django.template.context_processors.i18n",
212                 "django.template.context_processors.static",
213                 "django.template.context_processors.media",
214                 "django.template.context_processors.request",
215                 "django.template.context_processors.tz",
216                 "mezzanine.conf.context_processors.settings",
217                 "mezzanine.pages.context_processors.page",
218             ],
219             "builtins": [
220                 "mezzanine.template.loader_tags",
221             ],
222         },
223     },
224 ]
225
226 if DJANGO_VERSION < (1, 9):
227     del TEMPLATES[0]["OPTIONS"]["builtins"]
228
229
230 ################
231 # APPLICATIONS #
232 ################
233
234 INSTALLED_APPS = (
235     "mezzanine_api",
236     "rest_framework",
237     "rest_framework_swagger",
238     "oauth2_provider",
239     "django.contrib.admin",
240     "django.contrib.auth",
241     "django.contrib.contenttypes",
242     "django.contrib.redirects",
243     "django.contrib.sessions",
244     "django.contrib.sites",
245     "django.contrib.sitemaps",
246     "django.contrib.staticfiles",
247     "mezzanine.boot",
248     "mezzanine.conf",
249     "mezzanine.core",
250     "mezzanine.generic",
251     "mezzanine.pages",
252     "mezzanine.blog",
253     "mezzanine.forms",
254     "mezzanine.galleries",
255     "mezzanine.twitter",
256     # "mezzanine.accounts",
257     # "mezzanine.mobile",
258     "cms" ,
259     "storages",
260 )
261
262 # List of middleware classes to use. Order is important; in the request phase,
263 # these middleware classes will be applied in the order given, and in the
264 # response phase the middleware will be applied in reverse order.
265 MIDDLEWARE_CLASSES = (
266     "mezzanine.core.middleware.UpdateCacheMiddleware",
267     "mezzanine_api.middleware.ApiMiddleware",
268     'django.contrib.sessions.middleware.SessionMiddleware',
269     # Uncomment if using internationalisation or localisation
270     # 'django.middleware.locale.LocaleMiddleware',
271     'django.middleware.common.CommonMiddleware',
272     'django.middleware.csrf.CsrfViewMiddleware',
273     'django.contrib.auth.middleware.AuthenticationMiddleware',
274     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
275     'django.contrib.messages.middleware.MessageMiddleware',
276     'django.middleware.clickjacking.XFrameOptionsMiddleware',
277
278     "mezzanine.core.request.CurrentRequestMiddleware",
279     "mezzanine.core.middleware.RedirectFallbackMiddleware",
280     "mezzanine.core.middleware.TemplateForDeviceMiddleware",
281     "mezzanine.core.middleware.TemplateForHostMiddleware",
282     "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
283     "mezzanine.core.middleware.SitePermissionMiddleware",
284     "mezzanine.pages.middleware.PageMiddleware",
285     "mezzanine.core.middleware.FetchFromCacheMiddleware",
286 )
287
288 # Store these package names here as they may change in the future since
289 # at the moment we are using custom forks of them.
290 PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
291 PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
292
293 #########################
294 # OPTIONAL APPLICATIONS #
295 #########################
296
297 # These will be added to ``INSTALLED_APPS``, only if available.
298 OPTIONAL_APPS = (
299     "debug_toolbar",
300     "django_extensions",
301     "compressor",
302     PACKAGE_NAME_FILEBROWSER,
303     PACKAGE_NAME_GRAPPELLI,
304 )
305
306 #####################
307 # REST API SETTINGS #
308 #####################
309 try:
310     from mezzanine_api.settings import *
311 except ImportError:
312     pass
313
314
315 ##################
316 # LOCAL SETTINGS #
317 ##################
318
319 # Allow any settings to be defined in local_settings.py which should be
320 # ignored in your version control system allowing for settings to be
321 # defined per ma    chine.
322
323 # Instead of doing "from .local_settings import *", we use exec so that
324 # local_settings has full access to everything defined in this module.
325 # Also force into sys.modules so it's visible to Django's autoreload.
326
327 f = os.path.join(PROJECT_APP_PATH, "local_settings/__init__.py")
328 if os.path.exists(f):
329     import sys
330     import imp
331     module_name = "%s.local_settings" % PROJECT_APP
332     module = imp.new_module(module_name)
333     module.__file__ = f
334     sys.modules[module_name] = module
335     exec(open(f, "rb").read())
336
337
338 ####################
339 # DYNAMIC SETTINGS #
340 ####################
341
342 # set_dynamic_settings() will rewrite globals based on what has been
343 # defined so far, in order to provide some better defaults where
344 # applicable. We also allow this settings module to be imported
345 # without Mezzanine installed, as the case may be when using the
346 # fabfile, where setting the dynamic settings below isn't strictly
347 # required.
348 try:
349     from mezzanine.utils.conf import set_dynamic_settings
350 except ImportError:
351     pass
352 else:
353     set_dynamic_settings(globals())
354
355 # default settings for mezzanine
356 NEVERCACHE_KEY = os.getenv('CMS_NEVERCACHE_KEY', ''),
357 # Application User
358 CMS_APP_USER = os.getenv('CMS_APP_USER')
359 CMS_APP_USER_PASSWORD = os.getenv('CMS_APP_USER_PASSWORD')
360 CMS_APP_USER_MAIL = os.getenv('CMS_APP_USER_MAIL')
361 # Client App (EM)
362 CMS_APP_CLIENT_ID = os.getenv('CMS_APP_CLIENT_ID')
363 CMS_APP_CLIENT_SECRET = os.getenv('CMS_APP_CLIENT_SECRET')
364 CMS_APP_NAME = 'Engagement_Manager_App'
365 REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = (
366     'rest_framework.renderers.JSONRenderer',
367 )
368
369 # S3 configuration for static resources storage and media upload
370
371 # used by our custom storage.py
372 MEDIA_BUCKET = "cms-media"
373 STATIC_BUCKET = "cms-static"
374
375 # django-storages configuration
376 AWS_S3_HOST = os.environ['S3_HOST']
377 AWS_S3_PORT = int(os.environ['S3_PORT'])
378 AWS_S3_CUSTOM_DOMAIN = os.environ['S3_HOST']
379 AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
380 AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
381 AWS_AUTO_CREATE_BUCKET = True
382 AWS_PRELOAD_METADATA = True
383
384 # Set by custom subclass.
385 # AWS_STORAGE_BUCKET_NAME = "em-static"
386 AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
387 DEFAULT_FILE_STORAGE = 'cms.settings.storage.S3MediaStorage'
388 STATICFILES_STORAGE = 'cms.settings.storage.S3StaticStorage'
389
390 # These seem to have no effect even when we don't override with custom_domain?
391 STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, STATIC_BUCKET)
392 MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, MEDIA_BUCKET)
393
394 STATIC_ROOT = os.environ['STATIC_ROOT']
395