<commit_before>import os
from datetime import timedelta

from celery.schedules import crontab
from getenv import env

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

REQUIRED_ENVIRONMENT_VARIABLES = [
    'CDPT_ENVIRONMENT',
    'CDPT_DJANGO_SECRET_KEY',
    'CDPT_MAILGUN_USER',
    'CDPT_MAILGUN_PASS',
    'CDPT_ADMIN_PASS',
    'CDPT_DJANGO_PAYU_BASE_URL',
    'CDPT_DJANGO_PAYU_POS_ID',
    'CDPT_DJANGO_PAYU_POS_AUTHORIZATION_KEY',
    'CDPT_IFIRMA_USER',
    'CDPT_IFIRMA_INVOICE_KEY',
    'CDPT_IFIRMA_USER_KEY',
]

MISSING_ENVIRONMENT_VARIABLES = []
for e in REQUIRED_ENVIRONMENT_VARIABLES:
    if not env(e, required=False):
        MISSING_ENVIRONMENT_VARIABLES.append(e)

if MISSING_ENVIRONMENT_VARIABLES:
    raise Exception(
        '\n\nFollowing environment variables are missing:\n\t{}\n\nAdd all missing variables to: {}'.format(
            '\n\t'.join(MISSING_ENVIRONMENT_VARIABLES), '{}'.format(os.path.join(BASE_DIR, 'environment')
                                                                    ))
    )


# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('CDPT_DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env('CDPT_ENVIRONMENT') != 'PRODUCTION'

ALLOWED_HOSTS = [
    'backend.codepot.pl',
    'backend.codepot.pl.'
]

INSTALLED_DJANGO_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

INSTALLED_THIRD_PARTY_APPS = (
    'django_nose',
    'rest_framework',
    'rest_framework.authtoken',
    'corsheaders',
    'django_payu',
)

INSTALLED_HOME_GROWN_APPS = (
    'codepot',
)

INSTALLED_APPS = INSTALLED_DJANGO_APPS + INSTALLED_THIRD_PARTY_APPS + INSTALLED_HOME_GROWN_APPS

MIDDLEWARE_CLASSES = (
    'sslify.middleware.SSLifyMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'codepot.middleware.DisableCSRF',
    'django_payu.middleware.DjangoPayExceptionsMiddleware',
)

# Disable https forcing on development environment
SSLIFY_DISABLE = env('CDPT_ENVIRONMENT') != 'PRODUCTION'
protocol = 'https' if env('CDPT_ENVIRONMENT') == 'PRODUCTION' else 'http'
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'http')

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),<commit_msg>Update settings.py<commit_after>import os
from datetime import timedelta

from celery.schedules import crontab
from getenv import env

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

REQUIRED_ENVIRONMENT_VARIABLES = [
    'CDPT_ENVIRONMENT',
    'CDPT_DJANGO_SECRET_KEY',
    'CDPT_MAILGUN_USER',
    'CDPT_MAILGUN_PASS',
    'CDPT_ADMIN_PASS',
    'CDPT_DJANGO_PAYU_BASE_URL',
    'CDPT_DJANGO_PAYU_POS_ID',
    'CDPT_DJANGO_PAYU_POS_AUTHORIZATION_KEY',
    'CDPT_IFIRMA_USER',
    'CDPT_IFIRMA_INVOICE_KEY',
    'CDPT_IFIRMA_USER_KEY',
]

MISSING_ENVIRONMENT_VARIABLES = []
for e in REQUIRED_ENVIRONMENT_VARIABLES:
    if not env(e, required=False):
        MISSING_ENVIRONMENT_VARIABLES.append(e)

if MISSING_ENVIRONMENT_VARIABLES:
    raise Exception(
        '\n\nFollowing environment variables are missing:\n\t{}\n\nAdd all missing variables to: {}'.format(
            '\n\t'.join(MISSING_ENVIRONMENT_VARIABLES), '{}'.format(os.path.join(BASE_DIR, 'environment')
                                                                    ))
    )


# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('CDPT_DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env('CDPT_ENVIRONMENT') != 'PRODUCTION'

ALLOWED_HOSTS = [
    'backend.codepot.pl',
    'backend.codepot.pl.'
]

INSTALLED_DJANGO_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

INSTALLED_THIRD_PARTY_APPS = (
    'django_nose',
    'rest_framework',
    'rest_framework.authtoken',
    'corsheaders',
    'django_payu',
)

INSTALLED_HOME_GROWN_APPS = (
    'codepot',
)

INSTALLED_APPS = INSTALLED_DJANGO_APPS + INSTALLED_THIRD_PARTY_APPS + INSTALLED_HOME_GROWN_APPS

MIDDLEWARE_CLASSES = (
    'sslify.middleware.SSLifyMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'codepot.middleware.DisableCSRF',
    'django_payu.middleware.DjangoPayExceptionsMiddleware',
)

# Disable https forcing on development environment
SSLIFY_DISABLE = env('CDPT_ENVIRONMENT') != 'PRODUCTION'
protocol = 'https' if env('CDPT_ENVIRONMENT') == 'PRODUCTION' else 'http'
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', protocol)

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
{'fraction_non_alphanumeric': 0.10888108379327646, 'fraction_numerical': 0.0, 'mean_word_length': 4.3922452660054105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3550913', 'n_tokens_mistral': 2141, 'n_tokens_neox': 2116, 'n_words': 277}