[VVP] adding sonar coverage report to cms
[vvp/cms.git] / django / cms / settings / tox_settings.py
1 from __future__ import absolute_import, unicode_literals
2 import os
3 from cms.envbool import envbool
4
5 from django import VERSION as DJANGO_VERSION
6 from django.utils.translation import ugettext_lazy as _
7 from boto.s3.connection import OrdinaryCallingFormat
8
9
10 ######################
11 # MEZZANINE SETTINGS #
12 ######################
13
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
20
21 # Controls the ordering and grouping of the admin menu.
22 #
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",)),
28 # )
29
30 # A three item sequence, each containing a sequence of template tags
31 # used to render the admin dashboard.
32 #
33 # DASHBOARD_TAGS = (
34 #     ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
35 #     ("comment_tags.recent_comments",),
36 #     ("mezzanine_tags.recent_actions",),
37 # )
38
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.
45
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"),
50 # )
51
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.
60 #
61 # EXTRA_MODEL_FIELDS = (
62 #     (
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.
68 #         (_("Image"),),
69 #         # Keyword args for field class.
70 #         {"blank": True, "upload_to": "blog"},
71 #     ),
72 #     # Example of adding a field to *all* of Mezzanine's content types:
73 #     (
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},
78 #     ),
79 # )
80
81 # Setting to turn on featured images for blog posts. Defaults to False.
82 #
83 # BLOG_USE_FEATURED_IMAGE = True
84
85 # If True, the django-modeltranslation will be added to the
86 # INSTALLED_APPS setting.
87 USE_MODELTRANSLATION = False
88
89
90 ########################
91 # MAIN DJANGO SETTINGS #
92 ########################
93
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
96 ALLOWED_HOSTS = ['*']
97
98 # Set UTC time zone:
99 TIME_ZONE = 'UTC'
100 USE_TZ = True
101
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
108 # system time zone.
109 TIME_ZONE = 'UTC'
110
111 # If you set this to True, Django will use timezone-aware datetimes.
112 USE_TZ = True
113
114 # Language code for this installation. All choices can be found here:
115 # http://www.i18nguy.com/unicode/language-identifiers.html
116 LANGUAGE_CODE = "en"
117
118 # Supported languages
119 LANGUAGES = (
120     ('en', _('English')),
121 )
122
123 ENVIRONMENT = os.environ['ENVIRONMENT']
124
125 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
126 SECRET_KEY = os.environ["SECRET_KEY"]
127
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)
132
133 # Note: Only SSL email backends are allowed
134 EMAIL_USE_SSL = True
135
136 # Whether a user's session cookie expires when the Web browser is closed.
137 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
138
139 SITE_ID = 1
140
141 # If you set this to False, Django will make some optimizations so as not
142 # to load the internationalization machinery.
143 USE_I18N = False
144
145 AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
146
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
150
151
152 #############
153 # DATABASES #
154 #############
155
156 # Database
157 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
158 DATABASES = {
159     'default': {
160         'NAME': 'emdb.db',
161         'ENGINE': 'django.db.backends.sqlite3',
162         'TEST_NAME': 'emdb.db'
163
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'],
170     }
171 }
172
173 #########
174 # PATHS #
175 #########
176
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)
181
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
184 # project specific.
185 CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
186
187 # Package/module name to import the root urlpatterns from for the project.
188 ROOT_URLCONF = 'cms.urls'
189
190 TEMPLATES = [
191     {
192         "BACKEND": "django.template.backends.django.DjangoTemplates",
193         "DIRS": [
194             os.path.join(PROJECT_ROOT, "templates")
195         ],
196         "APP_DIRS": True,
197         "OPTIONS": {
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",
209             ],
210             "builtins": [
211                 "mezzanine.template.loader_tags",
212             ],
213         },
214     },
215 ]
216
217 if DJANGO_VERSION < (1, 9):
218     del TEMPLATES[0]["OPTIONS"]["builtins"]
219
220
221 ################
222 # APPLICATIONS #
223 ################
224
225 INSTALLED_APPS = (
226     "mezzanine_api",
227     "rest_framework",
228     "rest_framework_swagger",
229     "oauth2_provider",
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",
238     "mezzanine.boot",
239     "mezzanine.conf",
240     "mezzanine.core",
241     "mezzanine.generic",
242     "mezzanine.pages",
243     "mezzanine.blog",
244     "mezzanine.forms",
245     "mezzanine.galleries",
246     "mezzanine.twitter",
247     # "mezzanine.accounts",
248     # "mezzanine.mobile",
249     "cms",
250     "storages",
251     "django_jenkins"
252 )
253
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',
269
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",
278 )
279
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"
284
285 #########################
286 # OPTIONAL APPLICATIONS #
287 #########################
288
289 # These will be added to ``INSTALLED_APPS``, only if available.
290 OPTIONAL_APPS = (
291     "debug_toolbar",
292     "django_extensions",
293     "compressor",
294     PACKAGE_NAME_FILEBROWSER,
295     PACKAGE_NAME_GRAPPELLI,
296 )
297
298 #####################
299 # REST API SETTINGS #
300 #####################
301 try:
302     from mezzanine_api.settings import * # noqa ignore=F405
303 except ImportError:
304     pass
305
306
307 ##################
308 # LOCAL SETTINGS #
309 ##################
310
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.
314
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.
318
319 f = os.path.join(PROJECT_APP_PATH, "local_settings/__init__.py")
320 if os.path.exists(f):
321     import sys
322     import imp
323     module_name = "%s.local_settings" % PROJECT_APP
324     module = imp.new_module(module_name)
325     module.__file__ = f
326     sys.modules[module_name] = module
327     exec(open(f, "rb").read())
328
329
330 ####################
331 # DYNAMIC SETTINGS #
332 ####################
333
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
339 # required.
340 try:
341     from mezzanine.utils.conf import set_dynamic_settings
342 except ImportError:
343     pass
344 else:
345     set_dynamic_settings(globals())
346
347 # default settings for mezzanine
348 NEVERCACHE_KEY = os.getenv('CMS_NEVERCACHE_KEY', ''),
349 # Application User
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')
353 # Client App (EM)
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',
359 )
360
361 # S3 configuration for static resources storage and media upload
362
363 # used by our custom storage.py
364 MEDIA_BUCKET = "cms-media"
365 STATIC_BUCKET = "cms-static"
366
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
375
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'
381
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)
385
386 STATIC_ROOT = os.environ['STATIC_ROOT']