""" 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 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 = 'jelm*91lj(_-o20+6^a+bgv!4s6e_efry^#+f#=1ak&s1xr-2j' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ["*"] # fixme: production mode # 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', 'django_filters', 'polymorphic_tree', 'polymorphic', 'mptt', 'rest_framework', 'rest_framework.authtoken', 'drf_yasg', 'corsheaders', 'constance', 'constance.backends.database', ] + [ 'apps.auth.apps', 'apps.user', 'apps.notification', 'apps.payment', 'apps.course', 'apps.content', 'apps.school', ] if DEBUG: INSTALLED_APPS += ['silk'] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', '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', ] if DEBUG: MIDDLEWARE += ['silk.middleware.SilkyMiddleware'] ROOT_URLCONF = 'project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ 'project', ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'constance.context_processors.config', 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'project.wsgi.application' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases # DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # } # } DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'lilcity', 'USER': 'lilcity', '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' # Internationalization # https://docs.djangoproject.com/en/2.0/topics/i18n/ LANGUAGE_CODE = 'ru-RU' TIME_ZONE = 'UTC' 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"), ] MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, "media") LOGIN_URL = '/' # Email # https://github.com/anymail/django-anymail ANYMAIL = { "MAILGUN_API_KEY": "key-ec6af2d43d031d59bff6b1c8fb9390cb", "MAILGUN_SENDER_DOMAIN": 'mail.9ev.ru', } EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" DEFAULT_FROM_EMAIL = "postmaster@mail.9ev.ru" # SMS # https://github.com/twilio/twilio-python TWILIO_ACCOUNT = 'ACdf4a96b776cc764bc3ec0f0e136ba550' TWILIO_TOKEN = '559a6b1fce121759c9af2dcbb3f755ea' 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', ), '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, } # Celery settings CELERY_BROKER_URL = 'redis://redis:6379/0' CELERY_RESULT_BACKEND = 'redis://redis:6379/1' CELERY_TASK_SERIALIZER = 'json' CELERY_BEAT_SCHEDULE = { 'retrieve_photos_from_instagram': { 'task': 'apps.content.tasks.retrieve_photos', 'schedule': timedelta(minutes=2) if DEBUG else crontab(minute=0, hour=0), 'args': (), }, } # Dynamic settings CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' CONSTANCE_CONFIG = OrderedDict(( ('INSTAGRAM_CLIENT_ACCESS_TOKEN', ('7145314808.f6fa114.ce354a5d876041fc9d3db04b0045587d', '')), ('INSTAGRAM_CLIENT_SECRET', ('2334a921425140ccb180d145dcd35b25', '')), ('INSTAGRAM_PROFILE_URL', ('#', 'URL профиля Instagram.')), ('INSTAGRAM_RESULTS_TAG', ('#lil_акварель', 'Тэг результатов работ.')), ('INSTAGRAM_RESULTS_PATH', ('media/instagram/results/', 'Путь до результатов работ.')), ('SERVICE_COMMISSION', (10, 'Комиссия сервиса в процентах.')), ('SERVICE_DISCOUNT_MIN_AMOUNT', (3500, 'Минимальная сумма платежа для школы, после которой вычитывается скидка SERVICE_DISCOUNT.')), ('SERVICE_DISCOUNT', (1000, 'Комиссия сервиса при покупке всех дней.')), )) CONSTANCE_CONFIG_FIELDSETS = OrderedDict({ 'Service': ( 'SERVICE_COMMISSION', 'SERVICE_DISCOUNT_MIN_AMOUNT', 'SERVICE_DISCOUNT', ), 'Instagram': ( 'INSTAGRAM_CLIENT_ACCESS_TOKEN', 'INSTAGRAM_CLIENT_SECRET', 'INSTAGRAM_PROFILE_URL', 'INSTAGRAM_RESULTS_TAG', 'INSTAGRAM_RESULTS_PATH', ), }) try: from .local_settings import * except ImportError: pass try: from paymentwall import * except ImportError: pass else: Paymentwall.set_api_type(Paymentwall.API_GOODS) Paymentwall.set_app_key('d6f02b90cf6b16220932f4037578aff7') Paymentwall.set_secret_key('4ea515bf94e34cf28646c2e12a7b8707') # Mixpanel settings MIX_TOKEN = '79bd6bfd98667ed977737e6810b8abcd' # CORS settings if DEBUG: CORS_ORIGIN_ALLOW_ALL = True # Swagger doc settings SWAGGER_SETTINGS = { 'DOC_EXPANSION': 'none', }