text: """
  Django settings for palautebot project.
  """
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  import os
  
  import environ
  import raven
  
  root = environ.Path(__file__) - 2  # two folders back
  
  BASE_DIR = root()
  
  env = environ.Env(
      DEBUG=(bool, False),
      SECRET_KEY=(str, ''),
      ALLOWED_HOSTS=(list, []),
      ADMINS=(list, []),
      DATABASE_URL=(str, 'postgres:///palautebot'),
      JWT_SECRET_KEY=(str, ''),
      JWT_AUDIENCE=(str, ''),
      MEDIA_ROOT=(environ.Path(), root('media')),
      STATIC_ROOT=(environ.Path(), root('static')),
      MEDIA_URL=(str, '/media/'),
      STATIC_URL=(str, '/static/'),
      SENTRY_DSN=(str, ''),
      COOKIE_PREFIX=(str, 'palautebot'),
  )
  env.read_env(os.path.join(BASE_DIR, '.env'))
  
  DEBUG = env('DEBUG')
  ALLOWED_HOSTS = env('ALLOWED_HOSTS')
  ADMINS = env('ADMINS')
  
  DATABASES = {
      'default': env.db()
  }
  
  SITE_ID = 1
  
  # Application definition
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.sites',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
  
      'feedback',
  ]
  
  MIDDLEWARE = [
      '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',
  ]
  
  
  if env('SENTRY_DSN'):
      RAVEN_CONFIG = {
          'dsn': env('SENTRY_DSN'),
          'release': raven.fetch_git_sha(BASE_DIR),
      }
      INSTALLED_APPS.append('raven.contrib.django.raven_compat')
  
  
  ROOT_URLCONF = 'palautebot.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',
              ],
          },
      },
  ]
  WSGI_APPLICATION = 'palautebot.wsgi.application'
  
  # Internationalization
  # https://docs.djangoproject.com/en/1.8/topics/i18n/
  
  TIME_ZONE = 'Europe/Helsinki'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  LOCALE_PATHS = (
      os.path.join(BASE_DIR, 'locale'),
  )
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/1.8/howto/static-files/
  
  STATIC_URL = env('STATIC_URL')
  MEDIA_URL = env('MEDIA_URL')
  STATIC_ROOT = env('STATIC_ROOT')
  MEDIA_ROOT = env('MEDIA_ROOT')
  
  if env('SECRET_KEY'):
      SECRET_KEY = env('SECRET_KEY')
  
  
  # Palautebot settings
  
  TWITTER_CONSUMER_KEY = env('TWITTER_CONSUMER_KEY', default='')
  TWITTER_CONSUMER_SECRET = env('TWITTER_CONSUMER_SECRET', default='')
  TWITTER_ACCESS_TOKEN = env('TWITTER_ACCESS_TOKEN', default='')
  TWITTER_ACCESS_TOKEN_SECRET = env('TWITTER_ACCESS_TOKEN_SECRET', default='')
  
  # default max rate of tweets per user is 5 per day (60*24 minutes).
  # set either of the values to None to turn off rate limiting
  TWITTER_USER_RATE_LIMIT_AMOUNT = env.int('TWITTER_USER_RATE_LIMIT_AMOUNT', default=5)
  TWITTER_USER_RATE_LIMIT_PERIOD = env.int('TWITTER_USER_RATE_LIMIT_PERIOD', default=60*24)
  
  OPEN311_API_KEY = env('OPEN311_API_KEY', default='')
  OPEN311_API_SERVICE_CODE = env('OPEN311_API_SERVICE_CODE', default='')
  OPEN311_API_BASE_URL = env('OPEN311_API_BASE_URL', default='')
  OPEN311_FEEDBACK_URL = env.str(
      'OPEN311_FEEDBACK_URL',
      default='https://www.hel.fi/helsinki/fi/kaupunki-ja-hallinto/osallistu-ja-vaikuta/palaute/nayta-palaute?fid={}'
  )
  OPEN311_TICKET_POLLING_TIME = env.int('OPEN311_TICKET_POLLING_TIME', default=24*30)  # in hours, default 30 days
  
  SEARCH_STRING = env('SEARCH_STRING', default='')
  
  
  # local_settings.py can be used to override environment-specific settings
  # like database and email that differ between development and production.
  local_settings_path = os.path.join(BASE_DIR, "local_settings.py")
  if os.path.exists(local_settings_path):
      with open(local_settings_path) as fp:
          code = compile(fp.read(), local_settings_path, 'exec')
      exec(code, globals(), locals())
  
  
  # If a secret key was not supplied from elsewhere, generate a random one
  # and store it into a file called .django_secret.
  if 'SECRET_KEY' not in locals():
      secret_file = os.path.join(BASE_DIR, '.django_secret')
      try:
          with open(secret_file) as f:
              SECRET_KEY = f.read().strip()
      except IOError:
          import random
          system_random = random.SystemRandom()
          try:
              SECRET_KEY = ''.join([system_random.choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(64)])  # noqa
              secret = open(secret_file, 'w')
              os.chmod(secret_file, 0o0600)
              secret.write(SECRET_KEY)
              secret.close()
          except IOError:
              Exception('Please create a %s file with random characters to generate your secret key!' % secret_file)
  
  if DEBUG and 'LOGGING' not in locals():
      LOGGING = {
          'version': 1,
          'disable_existing_loggers': False,
          'handlers': {
              'console': {
                  'class': 'logging.StreamHandler',
              },
          },
          'loggers': {
              'feedback': {
                  'handlers': ['console'],
                  'level': 'DEBUG',
              },
          },
      }
  