override project settings

remotes/origin/HEAD
Max Yakovenko 8 years ago
parent 5ce8046928
commit 500bec7201
  1. 143
      eshop_project/settings/base.py
  2. 4
      eshop_project/settings/celery.py
  3. 27
      eshop_project/settings/development.py
  4. 40
      eshop_project/settings/production.py
  5. 166
      schema.xml
  6. 5
      wsgi.py

@ -11,10 +11,13 @@ https://docs.djangoproject.com/en/1.10/ref/settings/
""" """
import os import os
from django.urls import reverse_lazy
from .env import env from .env import env
# Site basic settings # Site basic settings
SITE_ID = env.str("SITE_ID")
SITE_HOST = env.str('SITE_HOST') SITE_HOST = env.str('SITE_HOST')
SITE_URL_HTTP = 'http://{}'.format(SITE_HOST) SITE_URL_HTTP = 'http://{}'.format(SITE_HOST)
SITE_URL_HTTPS = 'https://{}'.format(SITE_HOST) SITE_URL_HTTPS = 'https://{}'.format(SITE_HOST)
@ -31,52 +34,67 @@ SECRET_KEY = env.str('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG') DEBUG = env.bool('DEBUG')
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = tuple(env.list('ALLOWED_HOSTS', default=[])) ALLOWED_HOSTS = tuple(env.list('ALLOWED_HOSTS', default=[]))
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'suit',
'django.contrib.admin', 'core',
'accounts_ext',
'index',
'products',
'contact_us',
'debug_toolbar',
'registration',
'crispy_forms',
'captcha',
'mptt',
'import_export',
'jet',
'djcelery_email',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.postgres', 'django.contrib.postgres',
'debug_toolbar', 'django.contrib.sites',
'django.contrib.flatpages',
'import_export', 'django.contrib.admin',
'djcelery_email',
'mptt',
'landing',
'orders',
'loginsys',
'core',
'products',
'cart',
'discount',
'djcelery'
# 'landing',
# 'orders',
# 'auth_ext',
# 'cart',
# 'discount',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
] ]
ROOT_URLCONF = 'eshop_project.urls' ROOT_URLCONF = 'eshop_project.urls'
# Template settings
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')], 'DIRS': [TEMPLATE_DIR],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@ -84,26 +102,68 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'cart.context_processors.cart', 'contact_us.context_processors.contact_us_form',
# 'orders.context_processors.getting_basket_info', 'products.context_processors.product_search_form',
'products.context_processors.product_root_categories',
# 'cart.context_processors.cart',
], ],
}, },
}, },
] ]
# Crispy templatetags settings
CRISPY_TEMPLATE_PACK = 'bootstrap'
# Django simple captcha settings
CAPTCHA_TEST_MODE = env.bool("CAPTCHA_TEST_MODE")
CAPTCHA_OUTPUT_FORMAT = u'%(image)s %(hidden_field)s %(text_field)s'
CAPTCHA_IMAGE_SIZE = (250, 100)
CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.word_challenge'
# WSGI server definition
WSGI_APPLICATION = 'eshop_project.wsgi.application' WSGI_APPLICATION = 'eshop_project.wsgi.application'
MPTT_ADMIN_LEVEL_INDENT = 20 MPTT_ADMIN_LEVEL_INDENT = 20
# Database # Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = { DATABASES = {
'extra': { 'extra': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR,'eshop.sqlite') 'NAME': os.path.join(BASE_DIR,'eshop.sqlite.db')
} }
} }
# DJANGO REGISTRATION PACKAGE SETTINGS
ACCOUNT_ACTIVATION_DAYS = env.int('ACCOUNT_ACTIVATION_DAYS',default=1)
REGISTRATION_AUTO_LOGIN = env.int('REGISTRATION_AUTO_LOGIN',default=False)
REGISTRATION_OPEN = env.bool('REGISTRATION_OPEN', default=True)
REGISTRATION_EMAIL_HTML = env.bool("REGISTRATION_EMAIL_HTML", True)
REGISTRATION_FORM = 'accounts_ext.forms.RegistrationForm'
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.AllowAllUsersModelBackend',
]
# Authentication settings
LOGOUT_REDIRECT_URL = '/'
LOGIN_REDIRECT_URL = reverse_lazy('index:index')
# Email backend settings
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS')
EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL")
EMAIL_HOST = env.str('EMAIL_HOST')
EMAIL_PORT = env.int('EMAIL_PORT')
EMAIL_HOST_USER = env.str('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env.str('EMAIL_HOST_PASSWORD')
# Email fake validation settings
DISPOSABLE_EMAIL_DOMAINS = os.path.join(TEMPLATE_DIR, 'emails/disposable_email_domains.txt')
# Substituting auth user model
AUTH_USER_MODEL = 'accounts_ext.User'
# Password validation # Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
@ -143,49 +203,16 @@ USE_TZ = True
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATICFILES_DIRS = ( STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static", "static_dev"), os.path.join(BASE_DIR, "static"),
) )
STATIC_ROOT = os.path.join(BASE_DIR, "static/") # , "static_dev") STATIC_ROOT = os.path.join(BASE_DIR, "assets")
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "static", "media") MEDIA_ROOT = os.path.join(BASE_DIR, "assets", "media")
AUTH_PROFILE_MODULE = 'core.UserProfile'
CART_SESSION_ID = 'cart' CART_SESSION_ID = 'cart'
# Email server settings
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/eshop-messages'
# CELERY SETTINGS
import djcelery
djcelery.setup_loader()
BROKER_URL = 'amqp://localhost'
# BROKER_URL = 'amqp://78.155.219.170'
# BROKER_USER = "django_shop"
# BROKER_PASSWORD = "django_shop12345"
# for import-export excel data # for import-export excel data
IMPORT_EXPORT_USE_TRANSACTIONS = True IMPORT_EXPORT_USE_TRANSACTIONS = True
# WHOOSH_INDEX = os.path.join(os.path.dirname(__file__), "whoosh/")
# Uncomment for elasticsearch
# HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
# HAYSTACK_SEARCH_RESULTS_PER_PAGE = 12
# HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
# 'URL': 'http://127.0.0.1:9200',
# 'INDEX_NAME': 'haystack',
# # 'INCLUDE_SPELLING': True,
# },
# }
# STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

@ -3,5 +3,5 @@ from .base import *
CELERY_BROKER_URL= env.str('CELERY_BROKER_URL') CELERY_BROKER_URL= env.str('CELERY_BROKER_URL')
CELERY_RESULT_BACKEND = env.str('CELERY_RESULT_BACKEND') CELERY_RESULT_BACKEND = env.str('CELERY_RESULT_BACKEND')
CELERY_ACCEPT_CONTENT = tuple(env.list("CELERY_ACCEPT_CONTENT")) CELERY_ACCEPT_CONTENT = tuple(env.list("CELERY_ACCEPT_CONTENT"))
CELERY_RESULT_SERIALIZER = env.str('json') CELERY_RESULT_SERIALIZER = env.str('CELERY_RESULT_SERIALIZER')
CELERY_TASK_SERIALIZER = env.str('json') CELERY_TASK_SERIALIZER = env.str('CELERY_TASK_SERIALIZER')

@ -1,4 +1,6 @@
from .base import * from .base import *
_ = lambda s:s
# Database settings
DATABASES = { DATABASES = {
**DATABASES, **DATABASES,
@ -12,5 +14,28 @@ DATABASES = {
} }
} }
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' # Logging settings
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True
}
}
}

@ -1,20 +1,11 @@
from .base import * from .base import *
from .env import env
# Database settings. There must a database url # Database settings. There must a database url
DATABASES += { DATABASES = {
**DATABASES,
'default': env.db() 'default': env.db()
} }
# Email backend settings
EMAIL_BACKEND = env.str('EMAIL_BACKEND')
EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS')
EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL")
EMAIL_HOST = env.str('EMAIL_HOST')
EMAIL_PORT = env.int('EMAIL_PORT')
EMAIL_HOST_USER = env.str('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env.str('EMAIL_HOST_PASSWORD')
# Email user settings # Email user settings
ADMINS = ( ADMINS = (
('Dmitriy Belousov', 'dimkasp@mail.ru'), ('Dmitriy Belousov', 'dimkasp@mail.ru'),
@ -22,3 +13,30 @@ ADMINS = (
MANAGERS = ADMINS MANAGERS = ADMINS
DEFAULT_FROM_EMAIL = 'notreply@russianprograms' DEFAULT_FROM_EMAIL = 'notreply@russianprograms'
# Logging settings
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True
}
}
}

@ -1,166 +0,0 @@
<?xml version="1.0" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<schema name="default" version="1.5">
<types>
<fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
<fieldtype name="binary" class="solr.BinaryField"/>
<!-- Numeric field types that manipulate the value into
a string value that isn't human-readable in its internal form,
but with a lexicographic ordering the same as the numeric ordering,
so that range queries work correctly. -->
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
<fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
<!-- A Trie based date field for faster date range queries and date faceting. -->
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
<fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<fieldtype name="geohash" class="solr.GeoHashField"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
enablePositionIncrements="true"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
<filter class="solr.EnglishMinimalStemFilterFactory"/>
-->
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
enablePositionIncrements="true"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
<filter class="solr.EnglishMinimalStemFilterFactory"/>
-->
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
</analyzer>
</fieldType>
<fieldType name="ngram" class="solr.TextField" >
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="15" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="edge_ngram" class="solr.TextField" positionIncrementGap="1">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
</analyzer>
</fieldType>
</types>
<fields>
<!-- general -->
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="django_ct" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="_version_" type="long" indexed="true" stored ="true"/>
<dynamicField name="*_i" type="int" indexed="true" stored="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true"/>
<dynamicField name="*_l" type="long" indexed="true" stored="true"/>
<dynamicField name="*_t" type="text_en" indexed="true" stored="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_f" type="float" indexed="true" stored="true"/>
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
<dynamicField name="*_p" type="location" indexed="true" stored="true"/>
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false"/>
<field name="text" type="text_en" indexed="true" stored="true" multiValued="false" />
</fields>
<!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>id</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>text</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="AND"/>
</schema>

@ -1,5 +0,0 @@
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
Loading…
Cancel
Save