· 8 years ago · May 22, 2017, 12:14 PM
1
2from __future__ import absolute_import, unicode_literals
3import os
4
5from django import VERSION as DJANGO_VERSION
6from django.utils.translation import ugettext_lazy as _
7
8
9######################
10# MEZZANINE SETTINGS #
11######################
12
13# The following settings are already defined with default values in
14# the ``defaults.py`` module within each of Mezzanine's apps, but are
15# common enough to be put here, commented out, for conveniently
16# overriding. Please consult the settings documentation for a full list
17# of settings Mezzanine implements:
18# http://mezzanine.jupo.org/docs/configuration.html#default-settings
19
20# Controls the ordering and grouping of the admin menu.
21#
22# ADMIN_MENU_ORDER = (
23# ("Content", ("pages.Page", "blog.BlogPost",
24# "generic.ThreadedComment", (_("Media Library"), "media-library"),)),
25# ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
26# ("Users", ("auth.User", "auth.Group",)),
27# )
28
29ADMIN_REMOVAL = (
30 "mezzanine.generic.models.ThreadedComment ",
31 "mezzanine.pages.models.Link",
32 "mezzanine.forms.models.Form",
33 "mezzanine.galleries.models.Gallery",
34)
35
36# A three item sequence, each containing a sequence of template tags
37# used to render the admin dashboard.
38#
39# DASHBOARD_TAGS = (
40# ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
41# ("comment_tags.recent_comments",),
42# ("mezzanine_tags.recent_actions",),
43# )
44
45# A sequence of templates used by the ``page_menu`` template tag. Each
46# item in the sequence is a three item sequence, containing a unique ID
47# for the template, a label for the template, and the template path.
48# These templates are then available for selection when editing which
49# menus a page should appear in. Note that if a menu template is used
50# that doesn't appear in this setting, all pages will appear in it.
51
52# PAGE_MENU_TEMPLATES = (
53# (1, _("Top navigation bar"), "pages/menus/dropdown.html"),
54# (2, _("Left-hand tree"), "pages/menus/tree.html"),
55# (3, _("Footer"), "pages/menus/footer.html"),
56# )
57PAGE_MENU_TEMPLATES = ()
58
59# A sequence of fields that will be injected into Mezzanine's (or any
60# library's) models. Each item in the sequence is a four item sequence.
61# The first two items are the dotted path to the model and its field
62# name to be added, and the dotted path to the field class to use for
63# the field. The third and fourth items are a sequence of positional
64# args and a dictionary of keyword args, to use when creating the
65# field instance. When specifying the field class, the path
66# ``django.models.db.`` can be omitted for regular Django model fields.
67#
68# EXTRA_MODEL_FIELDS = (
69# (
70# # Dotted path to field.
71# "mezzanine.blog.models.BlogPost.image",
72# # Dotted path to field class.
73# "somelib.fields.ImageField",
74# # Positional args for field class.
75# (_("Image"),),
76# # Keyword args for field class.
77# {"blank": True, "upload_to": "blog"},
78# ),
79# # Example of adding a field to *all* of Mezzanine's content types:
80# (
81# "mezzanine.pages.models.Page.another_field",
82# "IntegerField", # 'django.db.models.' is implied if path is omitted.
83# (_("Another name"),),
84# {"blank": True, "default": 1},
85# ),
86# )
87
88# Setting to turn on featured images for blog posts. Defaults to False.
89#
90# BLOG_USE_FEATURED_IMAGE = True
91
92# If True, the django-modeltranslation will be added to the
93# INSTALLED_APPS setting.
94USE_MODELTRANSLATION = False
95
96
97########################
98# MAIN DJANGO SETTINGS #
99########################
100# Make these unique, and don't share it with anybody.
101SECRET_KEY = "0"
102NEVERCACHE_KEY = "1"
103
104# Hosts/domain names that are valid for this site; required if DEBUG is False
105# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
106ALLOWED_HOSTS = ['localhost', '127.0.0.1']
107
108FILEBROWSER_EXTENSIONS = {
109 'Image': ['.JPG', '.JPEG', '.GIF', '.PNG', '.TIF', '.TIFF',
110 '.jpg', '.jpeg', '.gif', '.png', '.tif', '.tiff'],
111}
112
113# Local time zone for this installation. Choices can be found here:
114# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
115# although not all choices may be available on all operating systems.
116# On Unix systems, a value of None will cause Django to use the same
117# timezone as the operating system.
118# If running in a Windows environment this must be set to the same as your
119# system time zone.
120TIME_ZONE = 'Asia/Yekaterinburg'
121
122# If you set this to True, Django will use timezone-aware datetimes.
123USE_TZ = False
124
125# Language code for this installation. All choices can be found here:
126# http://www.i18nguy.com/unicode/language-identifiers.html
127LANGUAGE_CODE = "ru"
128
129# Supported languages
130LANGUAGES = (('ru', _('Russian')),)
131
132# A boolean that turns on/off debug mode. When set to ``True``, stack traces
133# are displayed for error pages. Should always be set to ``False`` in
134# production. Best set to ``True`` in local_settings.py
135DEBUG = False
136
137# Whether a user's session cookie expires when the Web browser is closed.
138SESSION_EXPIRE_AT_BROWSER_CLOSE = True
139
140SITE_ID = 1
141
142# If you set this to False, Django will make some optimizations so as not
143# to load the internationalization machinery.
144USE_I18N = True
145
146AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
147
148# The numeric mode to set newly-uploaded files to. The value should be
149# a mode you'd pass directly to os.chmod.
150FILE_UPLOAD_PERMISSIONS = 0o644
151
152
153#############
154# DATABASES #
155#############
156
157DATABASES = {
158 "default": {
159 # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
160 "ENGINE": "django.db.backends.postgresql_psycopg2",
161 # DB name or path to database file if using sqlite3.
162 "NAME": "NAME",
163 # Not used with sqlite3.
164 "USER": "USER",
165 # Not used with sqlite3.
166 "PASSWORD": "PASSWORD",
167 # Set to empty string for localhost. Not used with sqlite3.
168 "HOST": "localhost", # "10.20.0.76",
169 # Set to empty string for default. Not used with sqlite3.
170 "PORT": "5432",
171 },
172 "mdm": {
173 "ENGINE": "django.db.backends.oracle",
174 "NAME": "NAME",
175 "USER": "USER",
176 "PASSWORD": "PASSWORD",
177 "HOST": "HOST.loc",
178 "PORT": "1521",
179 "OPTIONS": {
180 'threaded': True,
181 }
182 }
183}
184DATABASE_ROUTERS = ['mdm_upload.mdm_router.MdmRouter']
185
186#########
187# PATHS #
188#########
189
190# Full filesystem path to the project.
191PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
192PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
193PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
194
195# Every cache key will get prefixed with this value - here we set it to
196# the name of the directory the project is in to try and use something
197# project specific.
198CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
199
200# URL prefix for static files.
201# Example: "http://media.lawrence.com/static/"
202STATIC_URL = "/static/"
203
204# Absolute path to the directory static files should be collected to.
205# Don't put anything in this directory yourself; store your static files
206# in apps' "static/" subdirectories and in STATICFILES_DIRS.
207# Example: "/home/media/media.lawrence.com/static/"
208STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
209
210# URL that handles the media served from MEDIA_ROOT. Make sure to use a
211# trailing slash.
212# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
213MEDIA_URL = "/media/"
214
215# Absolute filesystem path to the directory that will hold user-uploaded files.
216# Example: "/home/media/media.lawrence.com/media/"
217MEDIA_ROOT = os.path.join(PROJECT_ROOT, MEDIA_URL.strip("/"))
218
219# Package/module name to import the root urlpatterns from for the project.
220ROOT_URLCONF = "%s.urls" % PROJECT_APP
221
222TEMPLATES = [
223 {
224 "BACKEND": "django.template.backends.django.DjangoTemplates",
225 "DIRS": [
226 os.path.join(PROJECT_ROOT, "templates")
227 ],
228 "APP_DIRS": True,
229 "OPTIONS": {
230 "context_processors": [
231 "django.contrib.auth.context_processors.auth",
232 "django.contrib.messages.context_processors.messages",
233 "django.template.context_processors.debug",
234 "django.template.context_processors.i18n",
235 "django.template.context_processors.static",
236 "django.template.context_processors.media",
237 "django.template.context_processors.request",
238 "django.template.context_processors.tz",
239 "mezzanine.conf.context_processors.settings",
240 "mezzanine.pages.context_processors.page",
241 ],
242 "builtins": [
243 "mezzanine.template.loader_tags",
244 ],
245 },
246 },
247]
248
249if DJANGO_VERSION < (1, 9):
250 del TEMPLATES[0]["OPTIONS"]["builtins"]
251
252JQUERY_FILENAME = "jquery-1.8.3.min.js"
253JQUERY_USER_UI_FILENAME = "jquery-ui.1.12.0.min.js"
254JQUERY_USER_FILENAME = "jquery-1.12.4.min.js"
255
256################
257# APPLICATIONS #
258################
259
260INSTALLED_APPS = (
261 "django.contrib.admin",
262 "django.contrib.auth",
263 "django.contrib.contenttypes",
264 "django.contrib.redirects",
265 "django.contrib.sessions",
266 "django.contrib.sites",
267 "django.contrib.sitemaps",
268 "django.contrib.staticfiles",
269 "mezzanine.boot",
270 "mezzanine.conf",
271 "mezzanine.core",
272 "mezzanine.generic",
273 "mezzanine.pages",
274 "mezzanine.forms",
275 "mezzanine.galleries",
276 # "mezzanine.blog",
277 # "mezzanine.twitter",
278 # "mezzanine.accounts",
279 # "mezzanine.mobile",
280 'metacore',
281 'input_forms',
282 'mdm_upload',
283)
284
285# List of middleware classes to use. Order is important; in the request phase,
286# these middleware classes will be applied in the order given, and in the
287# response phase the middleware will be applied in reverse order.
288MIDDLEWARE_CLASSES = (
289 "mezzanine.core.middleware.UpdateCacheMiddleware",
290
291 'django.contrib.sessions.middleware.SessionMiddleware',
292 # Uncomment if using internationalisation or localisation
293 # 'django.middleware.locale.LocaleMiddleware',
294 'django.middleware.common.CommonMiddleware',
295 'django.middleware.csrf.CsrfViewMiddleware',
296 'django.contrib.auth.middleware.AuthenticationMiddleware',
297 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
298 'django.contrib.messages.middleware.MessageMiddleware',
299 'django.middleware.clickjacking.XFrameOptionsMiddleware',
300
301 "mezzanine.core.request.CurrentRequestMiddleware",
302 "mezzanine.core.middleware.RedirectFallbackMiddleware",
303 "mezzanine.core.middleware.TemplateForDeviceMiddleware",
304 "mezzanine.core.middleware.TemplateForHostMiddleware",
305 "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
306 "mezzanine.core.middleware.SitePermissionMiddleware",
307 "mezzanine.pages.middleware.PageMiddleware",
308 "mezzanine.core.middleware.FetchFromCacheMiddleware",
309)
310
311# Store these package names here as they may change in the future since
312# at the moment we are using custom forks of them.
313PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
314PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
315
316#########################
317# OPTIONAL APPLICATIONS #
318#########################
319
320# These will be added to ``INSTALLED_APPS``, only if available.
321OPTIONAL_APPS = (
322 "debug_toolbar",
323 "django_extensions",
324 "compressor",
325 PACKAGE_NAME_FILEBROWSER,
326 PACKAGE_NAME_GRAPPELLI,
327)
328
329
330####################
331# LOGGING #
332####################
333LOGGING = {
334 'version': 1,
335 'disable_existing_loggers': False,
336 'filters': {
337 'require_debug_false': {
338 '()': 'django.utils.log.RequireDebugFalse',
339 },
340 'require_debug_true': {
341 '()': 'django.utils.log.RequireDebugTrue',
342 },
343 },
344 'formatters': {
345 'django.server': {
346 '()': 'django.utils.log.ServerFormatter',
347 'format': '[%(server_time)s] %(message)s',
348 },
349 'main_formatter': {
350 'format': '\r\n[%(asctime)s] %(message)s '
351 '(%(levelname)s:%(name)s; %(filename)s:%(lineno)d)',
352 'datefmt': "%Y-%m-%d %H:%M:%S",
353 },
354 },
355 'handlers': {
356 'console': {
357 'level': 'INFO',
358 'filters': ['require_debug_true'],
359 'class': 'logging.StreamHandler',
360 },
361 'django.server': {
362 'level': 'INFO',
363 'class': 'logging.StreamHandler',
364 'formatter': 'django.server',
365 },
366 'mail_admins': {
367 'level': 'ERROR',
368 'filters': ['require_debug_false'],
369 'class': 'django.utils.log.AdminEmailHandler'
370 },
371 'file': {
372 'level': 'WARNING',
373 # 'filters': ['require_debug_false'],
374 'class': 'logging.handlers.RotatingFileHandler',
375 'formatter': 'main_formatter',
376 'backupCount': 10,
377 'maxBytes': 1024 * 1024 * 15, # 15 MB
378 'filename': os.path.join(PROJECT_ROOT, 'logs/main.log'),
379 },
380 },
381 'loggers': {
382 'celery': {
383 'handlers': ['console', 'mail_admins', 'file'],
384 'level': 'WARNING',
385 },
386 'django': {
387 'handlers': ['console', 'mail_admins', 'file'],
388 'level': 'INFO',
389 },
390 'django.server': {
391 'handlers': ['django.server'],
392 'level': 'INFO',
393 'propagate': False,
394 },
395 'main_logger': {
396 'handlers': ['console', 'file'],
397 'level': 'WARNING',
398 },
399 },
400}
401
402
403####################
404# TASKING #
405####################
406CACHES = {
407 "default": {
408 "BACKEND": 'django.core.cache.backends.memcached.MemcachedCache',
409 "LOCATION": "unix:/var/run/memcached/memcached.socket",
410 },
411 "redis": {
412 "BACKEND": "django_redis.cache.RedisCache",
413 "LOCATION": "redis://:terminal-LOCATION@127.0.0.1:6379/0",
414 "OPTIONS": {
415 "CLIENT_CLASS": "django_redis.client.DefaultClient",
416 }
417 }
418}
419
420CELERY_BROKER_URL = "redis://:terminal-LOCATION@127.0.0.1:6379/0"
421CELERY_BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600}
422CELERY_TASK_SERIALIZER = 'json'
423CELERY_TIMEZONE = TIME_ZONE
424CELERY_TASK_TIME_LIMIT = 60*60*2
425CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(PROJECT_ROOT, 'logs/celerybeat-schedule')
426CELERY_WORKER_HIJACK_ROOT_LOGGER = False
427
428####################
429# USER SETTINGS #
430####################
431SOAP_URL = "SOAP_URL"
432SOAP_USER = "SOAP_USER"
433SOAP_PASSWORD = "SOAP_PASSWORD"
434
435
436##################
437# LOCAL SETTINGS #
438##################
439
440# Allow any settings to be defined in local_settings.py which should be
441# ignored in your version control system allowing for settings to be
442# defined per machine.
443
444# Instead of doing "from .local_settings import *", we use exec so that
445# local_settings has full access to everything defined in this module.
446# Also force into sys.modules so it's visible to Django's autoreload.
447
448f = os.path.join(PROJECT_APP_PATH, "local_settings.py")
449if os.path.exists(f):
450 import sys
451 import imp
452 module_name = "%s.local_settings" % PROJECT_APP
453 module = imp.new_module(module_name)
454 module.__file__ = f
455 sys.modules[module_name] = module
456 exec(open(f, "rb").read())
457
458
459####################
460# DYNAMIC SETTINGS #
461####################
462
463# set_dynamic_settings() will rewrite globals based on what has been
464# defined so far, in order to provide some better defaults where
465# applicable. We also allow this settings module to be imported
466# without Mezzanine installed, as the case may be when using the
467# fabfile, where setting the dynamic settings below isn't strictly
468# required.
469try:
470 from mezzanine.utils.conf import set_dynamic_settings
471except ImportError:
472 pass
473else:
474 set_dynamic_settings(globals())