1 # Copyright © 2018 Amdocs, AT&T, Bell Canada
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from __future__ import absolute_import, unicode_literals
17 from cms.envbool import envbool
19 from django import VERSION as DJANGO_VERSION
20 from django.utils.translation import ugettext_lazy as _
21 from boto.s3.connection import OrdinaryCallingFormat
24 ######################
25 # MEZZANINE SETTINGS #
26 ######################
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
35 # Controls the ordering and grouping of the admin menu.
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",)),
44 # A three item sequence, each containing a sequence of template tags
45 # used to render the admin dashboard.
48 # ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
49 # ("comment_tags.recent_comments",),
50 # ("mezzanine_tags.recent_actions",),
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.
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"),
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.
75 # EXTRA_MODEL_FIELDS = (
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.
83 # # Keyword args for field class.
84 # {"blank": True, "upload_to": "blog"},
86 # # Example of adding a field to *all* of Mezzanine's content types:
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},
95 # Setting to turn on featured images for blog posts. Defaults to False.
97 # BLOG_USE_FEATURED_IMAGE = True
99 # If True, the django-modeltranslation will be added to the
100 # INSTALLED_APPS setting.
101 USE_MODELTRANSLATION = False
104 ########################
105 # MAIN DJANGO SETTINGS #
106 ########################
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 = ['*']
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
125 # If you set this to True, Django will use timezone-aware datetimes.
128 # Language code for this installation. All choices can be found here:
129 # http://www.i18nguy.com/unicode/language-identifiers.html
132 # Supported languages
134 ('en', _('English')),
137 ENVIRONMENT = os.environ['ENVIRONMENT']
139 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
140 SECRET_KEY = os.environ["SECRET_KEY"]
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)
147 # Note: Only SSL email backends are allowed
150 # Whether a user's session cookie expires when the Web browser is closed.
151 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
155 # If you set this to False, Django will make some optimizations so as not
156 # to load the internationalization machinery.
159 AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
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
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'],
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)
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
194 CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
196 # Package/module name to import the root urlpatterns from for the project.
197 ROOT_URLCONF = 'cms.urls'
201 "BACKEND": "django.template.backends.django.DjangoTemplates",
203 os.path.join(PROJECT_ROOT, "templates")
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",
220 "mezzanine.template.loader_tags",
226 if DJANGO_VERSION < (1, 9):
227 del TEMPLATES[0]["OPTIONS"]["builtins"]
237 "rest_framework_swagger",
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",
254 "mezzanine.galleries",
256 # "mezzanine.accounts",
257 # "mezzanine.mobile",
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',
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",
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"
293 #########################
294 # OPTIONAL APPLICATIONS #
295 #########################
297 # These will be added to ``INSTALLED_APPS``, only if available.
302 PACKAGE_NAME_FILEBROWSER,
303 PACKAGE_NAME_GRAPPELLI,
306 #####################
307 # REST API SETTINGS #
308 #####################
310 from mezzanine_api.settings import *
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.
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.
327 f = os.path.join(PROJECT_APP_PATH, "local_settings/__init__.py")
328 if os.path.exists(f):
331 module_name = "%s.local_settings" % PROJECT_APP
332 module = imp.new_module(module_name)
334 sys.modules[module_name] = module
335 exec(open(f, "rb").read())
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
349 from mezzanine.utils.conf import set_dynamic_settings
353 set_dynamic_settings(globals())
355 # default settings for mezzanine
356 NEVERCACHE_KEY = os.getenv('CMS_NEVERCACHE_KEY', ''),
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')
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',
369 # S3 configuration for static resources storage and media upload
371 # used by our custom storage.py
372 MEDIA_BUCKET = "cms-media"
373 STATIC_BUCKET = "cms-static"
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
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'
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)
394 STATIC_ROOT = os.environ['STATIC_ROOT']