You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
292 lines
8.5 KiB
292 lines
8.5 KiB
'''
|
|
Django settings for project project.
|
|
|
|
Generated by 'django-admin startproject' using Django 2.0.1.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/2.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/2.0/ref/settings/
|
|
'''
|
|
|
|
import os
|
|
import raven
|
|
|
|
from celery.schedules import crontab
|
|
from collections import OrderedDict
|
|
from datetime import timedelta
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = os.getenv('SECRET_KEY', 'jelm*91lj(_-o20+6^a+bgv!4s6e_efry^#+f#=1ak&s1xr-2j')
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = os.getenv('DEBUG', False)
|
|
|
|
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '*').split(',')
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
] + [
|
|
'anymail',
|
|
'active_link',
|
|
'compressor',
|
|
'django_filters',
|
|
'polymorphic_tree',
|
|
'polymorphic',
|
|
'mptt',
|
|
'rest_framework',
|
|
'rest_framework.authtoken',
|
|
'drf_yasg',
|
|
'corsheaders',
|
|
'sorl.thumbnail',
|
|
'raven.contrib.django.raven_compat',
|
|
'django_user_agents',
|
|
'imagekit',
|
|
] + [
|
|
'apps.auth.apps',
|
|
'apps.user',
|
|
'apps.notification',
|
|
'apps.payment',
|
|
'apps.course',
|
|
'apps.content',
|
|
'apps.config',
|
|
'apps.school',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'django_user_agents.middleware.UserAgentMiddleware',
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
'apps.auth.middleware.TokenAuthLoginMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'project.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [
|
|
'project',
|
|
'templates',
|
|
],
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'project.context_processors.config',
|
|
'project.context_processors.baner',
|
|
'project.context_processors.is_summer_school_purchased',
|
|
'project.context_processors.referrer',
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
'loaders': [
|
|
# ('django.template.loaders.cached.Loader', [
|
|
'django.template.loaders.filesystem.Loader',
|
|
'django.template.loaders.app_directories.Loader',
|
|
# ]),
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'project.wsgi.application'
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': os.getenv('POSTGRES_DB', 'lilcity'),
|
|
'USER': os.getenv('POSTGRES_USER', 'lilcity'),
|
|
'PASSWORD': os.getenv('POSTGRES_PASSWORD', 'GPVs/E/{5&qe'),
|
|
'HOST': os.getenv('DATABASE_SERVICE_HOST', '127.0.0.1'),
|
|
'PORT': 5432,
|
|
}
|
|
}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
},
|
|
]
|
|
|
|
AUTH_USER_MODEL = 'user.User'
|
|
|
|
AUTHENTICATION_BACKENDS = ['apps.auth.backend.CaseInsensitiveModelBackend']
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/2.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'ru-RU'
|
|
|
|
TIME_ZONE = 'Europe/Moscow'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
# USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, 'web/build'),
|
|
]
|
|
STATICFILES_FINDERS = [
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
'compressor.finders.CompressorFinder',
|
|
]
|
|
|
|
MEDIA_URL = '/media/'
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
|
|
|
LOGIN_URL = '/'
|
|
# Email
|
|
# https://github.com/anymail/django-anymail
|
|
|
|
ANYMAIL = {
|
|
'MAILGUN_API_KEY': os.getenv('MAILGUN_API_KEY', 'key-ec6af2d43d031d59bff6b1c8fb9390cb'),
|
|
'MAILGUN_SENDER_DOMAIN': os.getenv('MAILGUN_SENDER_DOMAIN', 'mail.9ev.ru'),
|
|
}
|
|
EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend'
|
|
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'postmaster@mail.9ev.ru')
|
|
|
|
|
|
# SMS
|
|
# https://github.com/twilio/twilio-python
|
|
|
|
TWILIO_ACCOUNT = os.getenv('TWILIO_ACCOUNT', 'ACdf4a96b776cc764bc3ec0f0e136ba550')
|
|
TWILIO_TOKEN = os.getenv('TWILIO_TOKEN', '559a6b1fce121759c9af2dcbb3f755ea')
|
|
TWILIO_FROM_PHONE = os.getenv('TWILIO_FROM_PHONE', '+37128914409')
|
|
|
|
ACTIVE_LINK_STRICT = True
|
|
|
|
# DRF settings
|
|
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
'rest_framework.authentication.TokenAuthentication',
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
),
|
|
'DEFAULT_PERMISSION_CLASSES': (
|
|
'rest_framework.permissions.AllowAny',
|
|
),
|
|
'DEFAULT_RENDERER_CLASSES': (
|
|
'rest_framework.renderers.JSONRenderer',
|
|
# 'rest_framework.renderers.BrowsableAPIRenderer',
|
|
),
|
|
'DEFAULT_FILTER_BACKENDS': (
|
|
'django_filters.rest_framework.DjangoFilterBackend',
|
|
'rest_framework.filters.SearchFilter',
|
|
'rest_framework.filters.OrderingFilter',
|
|
),
|
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
|
'PAGE_SIZE': 10,
|
|
'EXCEPTION_HANDLER': 'project.exceptions.exception_handler',
|
|
}
|
|
|
|
# Celery settings
|
|
|
|
CELERY_BROKER_URL = os.getenv('REDIS_SERVICE_HOST', 'redis://redis:6379/') + os.getenv('REDIS_BROKER_DB', '0')
|
|
CELERY_RESULT_BACKEND = os.getenv('REDIS_SERVICE_HOST', 'redis://redis:6379/') + os.getenv('REDIS_RESULTS_DB', '1')
|
|
CELERY_TASK_SERIALIZER = 'json'
|
|
|
|
CELERY_BEAT_SCHEDULE = {
|
|
'retrieve_photos_from_instagram': {
|
|
'task': 'apps.content.tasks.retrieve_photos',
|
|
'schedule': timedelta(minutes=5) if DEBUG else crontab(minute=0, hour=0),
|
|
'args': (),
|
|
},
|
|
'update_users_in_roistat': {
|
|
'task': 'apps.user.tasks.users_to_roistat',
|
|
'schedule': timedelta(hours=1),
|
|
'args': (),
|
|
},
|
|
}
|
|
|
|
try:
|
|
from paymentwall import *
|
|
except ImportError:
|
|
pass
|
|
else:
|
|
Paymentwall.set_api_type(Paymentwall.API_GOODS)
|
|
Paymentwall.set_app_key(os.getenv('PAYMENTWALL_APP_KEY', 'd6f02b90cf6b16220932f4037578aff7'))
|
|
Paymentwall.set_secret_key(os.getenv('PAYMENTWALL_SECRET_KEY', '4ea515bf94e34cf28646c2e12a7b8707'))
|
|
|
|
# Mixpanel settings
|
|
MIX_TOKEN = os.getenv('MIXPANEL_TOKEN', '79bd6bfd98667ed977737e6810b8abcd')
|
|
|
|
# CORS settings
|
|
|
|
if DEBUG:
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
else:
|
|
CORS_ORIGIN_WHITELIST = os.getenv('CORS_ORIGIN_WHITELIST', 'lilcity.9ev.ru:8080').split(',')
|
|
|
|
# Swagger doc settings
|
|
|
|
SWAGGER_SETTINGS = {
|
|
'DOC_EXPANSION': 'none',
|
|
}
|
|
|
|
# Raven settings
|
|
RAVEN_CONFIG = {
|
|
'dsn': os.getenv('RAVEN_DSN', 'https://b545dac0ae0545a1bcfc443326fe5850:6f9c900cef7f4c11b63561030b37d15c@sentry.io/1197254'),
|
|
# If you are using git, you can also automatically configure the
|
|
# release based on the git info.
|
|
'release': raven.fetch_git_sha(BASE_DIR),
|
|
}
|
|
|
|
# Roistat counter id
|
|
ROISTAT_API_URL = 'https://cloud.roistat.com/api/v1'
|
|
ROISTAT_COUNTER_ID = os.getenv('ROISTAT_COUNTER_ID', None)
|
|
ROISTAT_PROJECT = os.getenv('ROISTAT_PROJECT', None)
|
|
ROISTAT_KEY = os.getenv('ROISTAT_KEY', None)
|
|
|
|
INSTAGRAM_RESULTS_PATH = 'media/instagram/results/'
|
|
|
|
DATA_UPLOAD_MAX_MEMORY_SIZE = 20242880
|
|
|
|
COMPRESS_ENABLED = True
|
|
|
|
try:
|
|
from .local_settings import *
|
|
except ImportError:
|
|
pass
|
|
|