1 from __future__ import absolute_import, unicode_literals
3 from cms.envbool import envbool
5 from django import VERSION as DJANGO_VERSION
6 from django.utils.translation import ugettext_lazy as _
7 from boto.s3.connection import OrdinaryCallingFormat
10 ######################
11 # MEZZANINE SETTINGS #
12 ######################
14 # The following settings are already defined with default values in
15 # the ``defaults.py`` module within each of Mezzanine's apps, but are
16 # common enough to be put here, commented out, for conveniently
17 # overriding. Please consult the settings documentation for a full list
18 # of settings Mezzanine implements:
19 # http://mezzanine.jupo.org/docs/configuration.html#default-settings
21 # Controls the ordering and grouping of the admin menu.
23 # ADMIN_MENU_ORDER = (
24 # ("Content", ("pages.Page", "blog.BlogPost",
25 # "generic.ThreadedComment", (_("Media Library"), "media-library"),)),
26 # ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
27 # ("Users", ("auth.User", "auth.Group",)),
30 # A three item sequence, each containing a sequence of template tags
31 # used to render the admin dashboard.
34 # ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
35 # ("comment_tags.recent_comments",),
36 # ("mezzanine_tags.recent_actions",),
39 # A sequence of templates used by the ``page_menu`` template tag. Each
40 # item in the sequence is a three item sequence, containing a unique ID
41 # for the template, a label for the template, and the template path.
42 # These templates are then available for selection when editing which
43 # menus a page should appear in. Note that if a menu template is used
44 # that doesn't appear in this setting, all pages will appear in it.
46 # PAGE_MENU_TEMPLATES = (
47 # (1, _("Top navigation bar"), "pages/menus/dropdown.html"),
48 # (2, _("Left-hand tree"), "pages/menus/tree.html"),
49 # (3, _("Footer"), "pages/menus/footer.html"),
52 # A sequence of fields that will be injected into Mezzanine's (or any
53 # library's) models. Each item in the sequence is a four item sequence.
54 # The first two items are the dotted path to the model and its field
55 # name to be added, and the dotted path to the field class to use for
56 # the field. The third and fourth items are a sequence of positional
57 # args and a dictionary of keyword args, to use when creating the
58 # field instance. When specifying the field class, the path
59 # ``django.models.db.`` can be omitted for regular Django model fields.
61 # EXTRA_MODEL_FIELDS = (
63 # # Dotted path to field.
64 # "mezzanine.blog.models.BlogPost.image",
65 # # Dotted path to field class.
66 # "somelib.fields.ImageField",
67 # # Positional args for field class.
69 # # Keyword args for field class.
70 # {"blank": True, "upload_to": "blog"},
72 # # Example of adding a field to *all* of Mezzanine's content types:
74 # "mezzanine.pages.models.Page.another_field",
75 # "IntegerField", # 'django.db.models.' is implied if path is omitted.
76 # (_("Another name"),),
77 # {"blank": True, "default": 1},
81 # Setting to turn on featured images for blog posts. Defaults to False.
83 # BLOG_USE_FEATURED_IMAGE = True
85 # If True, the django-modeltranslation will be added to the
86 # INSTALLED_APPS setting.
87 USE_MODELTRANSLATION = False
90 ########################
91 # MAIN DJANGO SETTINGS #
92 ########################
94 # Hosts/domain names that are valid for this site; required if DEBUG is False
95 # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
102 # Local time zone for this installation. Choices can be found here:
103 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
104 # although not all choices may be available on all operating systems.
105 # On Unix systems, a value of None will cause Django to use the same
106 # timezone as the operating system.
107 # If running in a Windows environment this must be set to the same as your
111 # If you set this to True, Django will use timezone-aware datetimes.
114 # Language code for this installation. All choices can be found here:
115 # http://www.i18nguy.com/unicode/language-identifiers.html
118 # Supported languages
120 ('en', _('English')),
123 ENVIRONMENT = os.environ['ENVIRONMENT']
125 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
126 SECRET_KEY = os.environ["SECRET_KEY"]
128 # A boolean that turns on/off debug mode. When set to ``True``, stack traces
129 # are displayed for error pages. Should always be set to ``False`` in
130 # production. Best set to ``True`` in local_settings.py
131 DEBUG = envbool('DJANGO_DEBUG_MODE', False)
133 # Note: Only SSL email backends are allowed
136 # Whether a user's session cookie expires when the Web browser is closed.
137 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
141 # If you set this to False, Django will make some optimizations so as not
142 # to load the internationalization machinery.
145 AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
147 # The numeric mode to set newly-uploaded files to. The value should be
148 # a mode you'd pass directly to os.chmod.
149 FILE_UPLOAD_PERMISSIONS = 0o644
157 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
161 'ENGINE': 'django.db.backends.sqlite3',
162 'TEST_NAME': 'emdb.db'
164 # 'ENGINE': 'django.db.backends.postgresql',
165 # 'NAME': os.environ['PGDATABASE'],
166 # 'USER': os.environ['PGUSER'],
167 # 'PASSWORD': os.environ['PGPASSWORD'],
168 # 'HOST': os.environ['PGHOST'],
169 # 'PORT': os.environ['PGPORT'],
177 # Full filesystem path to the project.
178 PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
179 PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
180 PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
182 # Every cache key will get prefixed with this value - here we set it to
183 # the name of the directory the project is in to try and use something
185 CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
187 # Package/module name to import the root urlpatterns from for the project.
188 ROOT_URLCONF = 'cms.urls'
192 "BACKEND": "django.template.backends.django.DjangoTemplates",
194 os.path.join(PROJECT_ROOT, "templates")
198 "context_processors": [
199 "django.contrib.auth.context_processors.auth",
200 "django.contrib.messages.context_processors.messages",
201 "django.template.context_processors.debug",
202 "django.template.context_processors.i18n",
203 "django.template.context_processors.static",
204 "django.template.context_processors.media",
205 "django.template.context_processors.request",
206 "django.template.context_processors.tz",
207 "mezzanine.conf.context_processors.settings",
208 "mezzanine.pages.context_processors.page",
211 "mezzanine.template.loader_tags",
217 if DJANGO_VERSION < (1, 9):
218 del TEMPLATES[0]["OPTIONS"]["builtins"]
228 "rest_framework_swagger",
230 "django.contrib.admin",
231 "django.contrib.auth",
232 "django.contrib.contenttypes",
233 "django.contrib.redirects",
234 "django.contrib.sessions",
235 "django.contrib.sites",
236 "django.contrib.sitemaps",
237 "django.contrib.staticfiles",
245 "mezzanine.galleries",
247 # "mezzanine.accounts",
248 # "mezzanine.mobile",
254 # List of middleware classes to use. Order is important; in the request phase,
255 # these middleware classes will be applied in the order given, and in the
256 # response phase the middleware will be applied in reverse order.
257 MIDDLEWARE_CLASSES = (
258 "mezzanine.core.middleware.UpdateCacheMiddleware",
259 "mezzanine_api.middleware.ApiMiddleware",
260 'django.contrib.sessions.middleware.SessionMiddleware',
261 # Uncomment if using internationalisation or localisation
262 # 'django.middleware.locale.LocaleMiddleware',
263 'django.middleware.common.CommonMiddleware',
264 'django.middleware.csrf.CsrfViewMiddleware',
265 'django.contrib.auth.middleware.AuthenticationMiddleware',
266 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
267 'django.contrib.messages.middleware.MessageMiddleware',
268 'django.middleware.clickjacking.XFrameOptionsMiddleware',
270 "mezzanine.core.request.CurrentRequestMiddleware",
271 "mezzanine.core.middleware.RedirectFallbackMiddleware",
272 "mezzanine.core.middleware.TemplateForDeviceMiddleware",
273 "mezzanine.core.middleware.TemplateForHostMiddleware",
274 "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
275 "mezzanine.core.middleware.SitePermissionMiddleware",
276 "mezzanine.pages.middleware.PageMiddleware",
277 "mezzanine.core.middleware.FetchFromCacheMiddleware",
280 # Store these package names here as they may change in the future since
281 # at the moment we are using custom forks of them.
282 PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
283 PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
285 #########################
286 # OPTIONAL APPLICATIONS #
287 #########################
289 # These will be added to ``INSTALLED_APPS``, only if available.
294 PACKAGE_NAME_FILEBROWSER,
295 PACKAGE_NAME_GRAPPELLI,
298 #####################
299 # REST API SETTINGS #
300 #####################
302 from mezzanine_api.settings import * # noqa ignore=F405
311 # Allow any settings to be defined in local_settings.py which should be
312 # ignored in your version control system allowing for settings to be
313 # defined per ma chine.
315 # Instead of doing "from .local_settings import *", we use exec so that
316 # local_settings has full access to everything defined in this module.
317 # Also force into sys.modules so it's visible to Django's autoreload.
319 f = os.path.join(PROJECT_APP_PATH, "local_settings/__init__.py")
320 if os.path.exists(f):
323 module_name = "%s.local_settings" % PROJECT_APP
324 module = imp.new_module(module_name)
326 sys.modules[module_name] = module
327 exec(open(f, "rb").read())
334 # set_dynamic_settings() will rewrite globals based on what has been
335 # defined so far, in order to provide some better defaults where
336 # applicable. We also allow this settings module to be imported
337 # without Mezzanine installed, as the case may be when using the
338 # fabfile, where setting the dynamic settings below isn't strictly
341 from mezzanine.utils.conf import set_dynamic_settings
345 set_dynamic_settings(globals())
347 # default settings for mezzanine
348 NEVERCACHE_KEY = os.getenv('CMS_NEVERCACHE_KEY', ''),
350 CMS_APP_USER = os.getenv('CMS_APP_USER')
351 CMS_APP_USER_PASSWORD = os.getenv('CMS_APP_USER_PASSWORD')
352 CMS_APP_USER_MAIL = os.getenv('CMS_APP_USER_MAIL')
354 CMS_APP_CLIENT_ID = os.getenv('CMS_APP_CLIENT_ID')
355 CMS_APP_CLIENT_SECRET = os.getenv('CMS_APP_CLIENT_SECRET')
356 CMS_APP_NAME = 'Engagement_Manager_App'
357 REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = ( # noqa ignore=F405
358 'rest_framework.renderers.JSONRenderer',
361 # S3 configuration for static resources storage and media upload
363 # used by our custom storage.py
364 MEDIA_BUCKET = "cms-media"
365 STATIC_BUCKET = "cms-static"
367 # django-storages configuration
368 AWS_S3_HOST = os.environ['S3_HOST']
369 AWS_S3_PORT = int(os.environ['S3_PORT'])
370 AWS_S3_CUSTOM_DOMAIN = os.environ['S3_HOST']
371 AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
372 AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
373 AWS_AUTO_CREATE_BUCKET = True
374 AWS_PRELOAD_METADATA = True
376 # Set by custom subclass.
377 # AWS_STORAGE_BUCKET_NAME = "em-static"
378 AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
379 DEFAULT_FILE_STORAGE = 'cms.settings.storage.S3MediaStorage'
380 STATICFILES_STORAGE = 'cms.settings.storage.S3StaticStorage'
382 # These seem to have no effect even when we don't override with custom_domain?
383 STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, STATIC_BUCKET)
384 MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, MEDIA_BUCKET)
386 STATIC_ROOT = os.environ['STATIC_ROOT']