<commit_before>"""
Django settings for contentcuration project.

Generated by 'django-admin startproject' using Django 1.8.1.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import logging
import os
import re
import sys
from datetime import datetime
from datetime import timedelta

import pycountry

from contentcuration.utils.incidents import INCIDENTS

logging.getLogger("newrelic").setLevel(logging.CRITICAL)
logging.getLogger("botocore").setLevel(logging.WARNING)
logging.getLogger("boto3").setLevel(logging.WARNING)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STORAGE_ROOT = "storage"
DB_ROOT = "databases"

STATIC_ROOT = os.getenv("STATICFILES_DIR") or os.path.join(BASE_DIR, "contentcuration", "static")
CSV_ROOT = "csvs"
EXPORT_ROOT = "exports"

BETA_MODE = os.getenv("STUDIO_BETA_MODE")
RUNNING_TESTS = (sys.argv[1:2] == ['test'] or os.path.basename(sys.argv[0]) == 'pytest')

# hardcoding all this info for now. Potential for shared reference with webpack?
WEBPACK_LOADER = {
    'DEFAULT': {
        # trailing empty string to include trailing /
        'BUNDLE_DIR_NAME': os.path.join('js', 'bundles', ''),
        'STATS_FILE': os.path.join(BASE_DIR, 'build', 'webpack-stats.json'),
    }
}

PERMISSION_TEMPLATE_ROOT = os.path.join(BASE_DIR, "contentcuration", "templates", "permissions")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") or <KEY>'

# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = True

SESSION_COOKIE_NAME = 'kolibri_studio_sessionid'

ALLOWED_HOSTS = ["*"]  # In production, we serve through a file socket, so this is OK.


# Application definition

INSTALLED_APPS = (
    'contentcuration.apps.ContentConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    'rest_framework',
    'raven.contrib.django.raven_compat',
    'django_js_reverse',
    'kolibri_content',
    'readonly',
    'email_extras',
    'le_utils',
    'rest_framework.authtoken',
    'search',
    'django_s3_storage',
    'webpack_loader',
    'django_filters',
    'mathfilters',
)

SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"

REDIS_URL = "redis://:{password}@{endpoint}:/".format(
    password=os.getenv("CELERY_REDIS_PASSWORD") or "",
    endpoint=os.getenv("CELERY_BROKER_ENDPOINT") or "localhost:6379")

CACHE_REDIS_DB = os.getenv("CACHE_REDIS_DB") or "1"

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': '{url}{db}'.format(url=REDIS_URL, db=CACHE_REDIS_DB),
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',<commit_msg>Fix URL typo that somehow worked fine under Python 2.<commit_after>"""
Django settings for contentcuration project.

Generated by 'django-admin startproject' using Django 1.8.1.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import logging
import os
import re
import sys
from datetime import datetime
from datetime import timedelta

import pycountry

from contentcuration.utils.incidents import INCIDENTS

logging.getLogger("newrelic").setLevel(logging.CRITICAL)
logging.getLogger("botocore").setLevel(logging.WARNING)
logging.getLogger("boto3").setLevel(logging.WARNING)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STORAGE_ROOT = "storage"
DB_ROOT = "databases"

STATIC_ROOT = os.getenv("STATICFILES_DIR") or os.path.join(BASE_DIR, "contentcuration", "static")
CSV_ROOT = "csvs"
EXPORT_ROOT = "exports"

BETA_MODE = os.getenv("STUDIO_BETA_MODE")
RUNNING_TESTS = (sys.argv[1:2] == ['test'] or os.path.basename(sys.argv[0]) == 'pytest')

# hardcoding all this info for now. Potential for shared reference with webpack?
WEBPACK_LOADER = {
    'DEFAULT': {
        # trailing empty string to include trailing /
        'BUNDLE_DIR_NAME': os.path.join('js', 'bundles', ''),
        'STATS_FILE': os.path.join(BASE_DIR, 'build', 'webpack-stats.json'),
    }
}

PERMISSION_TEMPLATE_ROOT = os.path.join(BASE_DIR, "contentcuration", "templates", "permissions")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") or <KEY>'

# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = True

SESSION_COOKIE_NAME = 'kolibri_studio_sessionid'

ALLOWED_HOSTS = ["*"]  # In production, we serve through a file socket, so this is OK.


# Application definition

INSTALLED_APPS = (
    'contentcuration.apps.ContentConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    'rest_framework',
    'raven.contrib.django.raven_compat',
    'django_js_reverse',
    'kolibri_content',
    'readonly',
    'email_extras',
    'le_utils',
    'rest_framework.authtoken',
    'search',
    'django_s3_storage',
    'webpack_loader',
    'django_filters',
    'mathfilters',
)

SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"

REDIS_URL = "redis://:{password}@{endpoint}/".format(
    password=os.getenv("CELERY_REDIS_PASSWORD") or "",
    endpoint=os.getenv("CELERY_BROKER_ENDPOINT") or "localhost:6379")

CACHE_REDIS_DB = os.getenv("CACHE_REDIS_DB") or "1"

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': '{url}{db}'.format(url=REDIS_URL, db=CACHE_REDIS_DB),
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
{'fraction_non_alphanumeric': 0.13566193669109622, 'fraction_numerical': 0.0060813971620146574, 'mean_word_length': 4.6017467248908295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2356202', 'n_tokens_mistral': 2233, 'n_tokens_neox': 2197, 'n_words': 442}