''' 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(',') MAIN_HOST = os.getenv('MAIN_HOST', 'lil.school') # 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.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', 'apps.auth.middleware.TempTokenAuthLoginMiddleware', ] ROOT_URLCONF = 'project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ 'project', 'templates', ], 'OPTIONS': { 'context_processors': [ 'project.context_processors.config', 'project.context_processors.banner', 'project.context_processors.school_purchased', 'project.context_processors.referrer', 'project.context_processors.settings', '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', ] STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' 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', ''), 'MAILGUN_SENDER_DOMAIN': os.getenv('MAILGUN_SENDER_DOMAIN', ''), } EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend' DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'postmaster@mail.9ev.ru') SENDGRID_API_KEY = os.getenv('SENDGRID_API_KEY') # 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 # PUSHER settings PUSHER_APP_ID = os.getenv('PUSHER_APP_ID', '') PUSHER_KEY = os.getenv('PUSHER_KEY', '') PUSHER_SECRET = os.getenv('PUSHER_SECRET', '') PUSHER_CLUSTER = 'eu' # 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': (), }, 'send_certificates': { 'task': 'apps.notification.tasks.send_certificates', 'schedule': crontab(minute=0, hour=19), 'args': (), }, 'sendgrid_update_recipients': { 'task': 'apps.notification.tasks.sendgrid_update_recipients', 'schedule': crontab(minute=0, hour=3), 'args': (), }, 'send_child_birthday_email_and_bonuses': { 'task': 'apps.notification.tasks.send_child_birthday_email_and_bonuses', 'schedule': crontab(minute=0, hour=0), 'args': (), }, 'send_june_camp_certificates': { 'task': 'apps.notification.tasks.send_camp_certificates', 'schedule': crontab(0, 9, day_of_month='1', month_of_year='7'), 'kwargs': {'certificate_number': 2}, }, 'send_jule_camp_certificates': { 'task': 'apps.notification.tasks.send_camp_certificates', 'schedule': crontab(0, 9, day_of_month='1', month_of_year='8'), 'kwargs': {'certificate_number': 2}, }, } 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