text: """
  Django settings for authors project.
  Generated by 'django-admin startproject' using Django 1.11.14.
  For more information on this file, see
  https://docs.djangoproject.com/en/1.11/topics/settings/
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/1.11/ref/settings/
  """
  
  import os
  import datetime
  import django_heroku
  
  
  # 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/1.11/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.environ.get('SECRET_KEY')
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  ALLOWED_HOSTS = ['*']
  
  # Application definition
  
  INSTALLED_APPS = [
      'channels',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
  
      'corsheaders',
      'django_extensions',
      'rest_framework',
  
      'authors.apps.authentication',
      'authors.apps.core',
      'authors.apps.profiles',
      'authors.apps.reactions',
      'authors.apps.articles',
      'authors.apps.comments',
      'authors.apps.followers',
      'authors.apps.favorites',
      'authors.apps.bookmark',
      'authors.apps.stats',
      'authors.apps.highlights',
  
      'drf_yasg',
      'django_inlinecss',
      'social_django',
      'simple_history',
      'cloudinary',
      'django_social_share',
      'notifications',
      'django_filters',
  ]
  
  MIDDLEWARE = [
      'django.middleware.common.CommonMiddleware',
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
      'social_django.middleware.SocialAuthExceptionMiddleware',
      'simple_history.middleware.HistoryRequestMiddleware',
      'corsheaders.middleware.CorsMiddleware',
  ]
  
  CORS_ORIGIN_ALLOW_ALL = True
  
  ROOT_URLCONF = 'authors.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
                  'social_django.context_processors.backends',
                  'social_django.context_processors.login_redirect',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'authors.wsgi.application'
  
  # Database
  # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': os.getenv('DBNAME'),
          'USER': os.getenv('DBUSER'),
          'PASSWORD': os.getenv('DBPASSWORD'),
          'HOST': os.getenv('DBHOST'),
          'PORT': os.getenv('DBPORT'),
      }
  }
  
  # Password validation
  # https://docs.djangoproject.com/en/1.11/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',
      },
  ]
  
  # Internationalization
  # https://docs.djangoproject.com/en/1.11/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/1.10/howto/static-files/
  
  STATIC_URL = '/static/'
  STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  STATICFILES_DIRS = (
      os.path.join(BASE_DIR, 'static'),
  )
  
  APPEND_SLASH = False
  
  CORS_ORIGIN_WHITELIST = (
      '0.0.0.0:4000',
      'localhost:4000',
  )
  
  # Tell Django about the custom `User` model we created. The string
  # `authentication.User` tells Django we are referring to the `User` model in
  # the `authentication` module. This module is registered above in a setting
  # called `INSTALLED_APPS`.
  AUTH_USER_MODEL = 'authentication.User'
  
  REST_FRAMEWORK = {
      'EXCEPTION_HANDLER': 'authors.apps.core.exceptions.core_exception_handler',
      'NON_FIELD_ERRORS_KEY': 'error',
  
      'DEFAULT_AUTHENTICATION_CLASSES': (
          # 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
          'authors.apps.authentication.backends.JWTAuthentication',
      ),
  
      'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination'
                                  '.PageNumberPagination',
      'PAGE_SIZE': 5
  }
  
  EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend'
  # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  EMAIL_HOST = os.environ.get('EMAIL_HOST')
  EMAIL_PORT = os.environ.get('EMAIL_PORT') or 587
  EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
  EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
  EMAIL_USE_TLS = True
  
  SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY')
  SENDGRID_SANDBOX_MODE_IN_DEBUG = False
  SENDGRID_ECHO_TO_STDOUT = True
  
  django_heroku.settings(locals())
  
  JWT_AUTH = {
      'JWT_ENCODE_HANDLER':
          'rest_framework_jwt.utils.jwt_encode_handler',
  
          'JWT_DECODE_HANDLER':
          'rest_framework_jwt.utils.jwt_decode_handler',
  
          'JWT_PAYLOAD_HANDLER':
          'rest_framework_jwt.utils.jwt_payload_handler',
  
          'JWT_PAYLOAD_GET_USER_ID_HANDLER':
          'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler',
  
          'JWT_RESPONSE_PAYLOAD_HANDLER':
          'rest_framework_jwt.utils.jwt_response_payload_handler',
  
          'JWT_SECRET_KEY': SECRET_KEY,
          'JWT_GET_USER_SECRET_KEY': None,
          'JWT_PUBLIC_KEY': None,
          'JWT_PRIVATE_KEY': None,
          'JWT_ALGORITHM': 'HS256',
          'JWT_VERIFY': True,
          'JWT_VERIFY_EXPIRATION': True,
          'JWT_LEEWAY': 0,
          'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=3),
          'JWT_AUDIENCE': None,
          'JWT_ISSUER': None,
          'JWT_ALLOW_REFRESH': False,
          'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=10800),
          'JWT_AUTH_HEADER_PREFIX': 'Bearer',
          'JWT_AUTH_COOKIE': None,
  }
  
  EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend'
  # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  EMAIL_HOST = os.environ.get('EMAIL_HOST')
  EMAIL_PORT = os.environ.get('EMAIL_PORT') or 587
  EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
  EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
  EMAIL_USE_TLS = True
  
  SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY')
  SENDGRID_SANDBOX_MODE_IN_DEBUG = False
  SENDGRID_ECHO_TO_STDOUT = True
  
  # Backends configurations for social authentication
  AUTHENTICATION_BACKENDS = (
      'social_core.backends.google.GoogleOAuth2',
      'social_core.backends.twitter.TwitterOAuth',
      'social_core.backends.facebook.FacebookOAuth2',
      'social_core.backends.facebook.FacebookAppOAuth2',
      'django.contrib.auth.backends.ModelBackend',
  )
  
  # Pipeline for social authentication
  SOCIAL_AUTH_PIPELINE = (
      'social_core.pipeline.social_auth.social_details',
      'social_core.pipeline.social_auth.social_uid',
      'social_core.pipeline.social_auth.social_user',
      'social_core.pipeline.user.get_username',
      'social_core.pipeline.social_auth.associate_by_email',
      'social_core.pipeline.user.create_user',
      'social_core.pipeline.social_auth.associate_user',
      'social_core.pipeline.social_auth.load_extra_data',
      'social_core.pipeline.user.user_details',
  )
  
  # Facebook configs
  SOCIAL_AUTH_FACEBOOK_KEY = os.getenv('FACEBOOK_APP_ID')
  SOCIAL_AUTH_FACEBOOK_SECRET = os.getenv('FACEBOOK_APP_SECRET')
  SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
  SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
      "fields": "id, email, name"
  }
  
  # Twitter configs
  SOCIAL_AUTH_TWITTER_KEY = os.getenv('TWITTER_KEY')
  SOCIAL_AUTH_TWITTER_SECRET = os.getenv('TWITTER_SECRET')
  SOCIAL_AUTH_TWITTER_SCOPE = ['email']
  
  CLOUDINARY = {
      'cloud_name': os.getenv('CLOUDINARY_NAME'),
      'api_key': os.getenv('CLOUDINARY_KEY'),
      'api_secret': os.getenv('CLOUDINARY_SECRET'),
      'secure': True
  }
  
  SWAGGER_SETTINGS = {
      'SECURITY_DEFINITIONS': {
          'Bearer': {
              'type': 'apiKey',
              'name': 'Authorization',
              'in': 'header'
          }
      }
  }
  
  ASGI_APPLICATION = "authors.routing.application"
  CHANNEL_LAYERS = {
      'default': {
          'BACKEND': 'channels_redis.core.RedisChannelLayer',
          'CONFIG': {
              "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
          }
      }
  }
  