<commit_before># -*- coding: utf-8 -*-

import os

CONTENTDIR = os.path.dirname(__file__)
PROJECTDIR = os.path.dirname(CONTENTDIR)

# Files
MEDIA_ROOT = os.path.join(PROJECTDIR, 'content/uploads/')
MEDIA_URL = '/uploads/'
STATIC_ROOT = os.path.join(PROJECTDIR, 'content/static/')
STATIC_URL = '/static/'

# Admin panel settings
ADMIN_LOGIN_URL = '/manage/auth/login/'
LOGIN_URL = '/users/login/'

STATICFILES_DIRS = (
    os.path.join(CONTENTDIR, 'static/'),
)

COMPRESS_OFFLINE = True
COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'django_libsass.SassCompiler'),
)
COMPRESS_CSS_FILTERS = (
    'compressor.filters.css_default.CssAbsoluteFilter',
    'compressor.filters.cssmin.rCSSMinFilter',
)

OAUTH2_PROVIDER = {
    'SCOPES': {
        'read': 'Read scope',
        'write': 'Write scope',
        'groups': 'Access to your groups'
    }
}

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'oauth2_provider.ext.rest_framework.TokenHasReadWriteScope',
    ],
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'oauth2_provider.ext.rest_framework.OAuth2Authentication',
    ]
}

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(CONTENTDIR, 'templates/'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.template.context_processors.request',
                'django.contrib.messages.context_processors.messages',
                'Instanssi.common.context_processors.short_language_code',
                'Instanssi.common.context_processors.google_settings',
                'social.apps.django_app.context_processors.backends',
                'social.apps.django_app.context_processors.login_redirect',
            ],
        },
    },
]

DEFAULT_FILE_STORAGE = 'Instanssi.common.storage.ASCIIFileSystemStorage'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

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',
    'Instanssi.common.http.Http403Middleware',
]

ROOT_URLCONF = 'Instanssi.urls'

INSTALLED_APPS = (
    'Instanssi.base_layout',
    'Instanssi.arkisto',
    'Instanssi.main2012',
    'Instanssi.main2013',
    'Instanssi.main2014',
    'Instanssi.main2015',
    'Instanssi.main2016',
    'Instanssi.main2017',
    'Instanssi.admin_base',
    'Instanssi.admin_arkisto',
    'Instanssi.admin_blog',
    'Instanssi.admin_upload',
    'Instanssi.admin_slides',
    'Instanssi.admin_events',
    'Instanssi.admin_kompomaatti',
    'Instanssi.admin_users',
    'Instanssi.admin_profile',
    'Instanssi.admin_programme',
    'Instanssi.admin_events_overview',
    'Instanssi.admin_utils',
    'Instanssi.admin_screenshow',
    'Instanssi.admin_store',
    'Instanssi.users',
    'Instanssi.kompomaatti',
    'Instanssi.ext_blog',
    'Instanssi.ext_programme',
    'Instanssi.screenshow',
    'Instanssi.dblog',
    'Instanssi.json_api',
    'Instanssi.store',
    'Instanssi.infodesk',
    'imagekit',
    'rest_framework',
    'oauth2_provider',
    'twitter_tag',
    'crispy_forms',
    'social.apps.django_app.default',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'formtools',
    'compressor',
)

# Authentication backends, notice the openid backend here.
AUTHENTICATION_BACKENDS = (
    'social.backends.open_id.OpenIdAuth',
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.google.GoogleOAuth2',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.github.GithubOAuth2',
    'social.backends.battlenet.BattleNetOAuth2',
    'social.backends.steam.SteamOpenId',
    'django.contrib.auth.backends.ModelBackend',
)


def enable_api_session_access():
    """
    This is for enabling debug mode, easier access for rest API testing
    :return:
    """
    REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'].append(
        'rest_framework.authentication.SessionAuthentication',
    )
    REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = [
        'rest_framework.permissions.AllowAny',
    ]


def make_cache_conf(debug_mode):
    if debug_mode:
        return {
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                'LOCATION': 'unique-snowflake'
            }
        }
    else:
        return {
            'default': {<commit_msg>api: Turn off browseable api and form api when DEBUG = false<commit_after># -*- coding: utf-8 -*-

import os

CONTENTDIR = os.path.dirname(__file__)
PROJECTDIR = os.path.dirname(CONTENTDIR)

# Files
MEDIA_ROOT = os.path.join(PROJECTDIR, 'content/uploads/')
MEDIA_URL = '/uploads/'
STATIC_ROOT = os.path.join(PROJECTDIR, 'content/static/')
STATIC_URL = '/static/'

# Admin panel settings
ADMIN_LOGIN_URL = '/manage/auth/login/'
LOGIN_URL = '/users/login/'

STATICFILES_DIRS = (
    os.path.join(CONTENTDIR, 'static/'),
)

COMPRESS_OFFLINE = True
COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'django_libsass.SassCompiler'),
)
COMPRESS_CSS_FILTERS = (
    'compressor.filters.css_default.CssAbsoluteFilter',
    'compressor.filters.cssmin.rCSSMinFilter',
)

OAUTH2_PROVIDER = {
    'SCOPES': {
        'read': 'Read scope',
        'write': 'Write scope',
        'groups': 'Access to your groups'
    }
}

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'oauth2_provider.ext.rest_framework.TokenHasReadWriteScope',
    ],
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'oauth2_provider.ext.rest_framework.OAuth2Authentication',
    ],
    'DEFAULT_RENDERER_CLASSES': [
        'rest_framework.renderers.JSONRenderer',
    ],
    'DEFAULT_PARSER_CLASSES': [
        'rest_framework.parsers.JSONParser',
    ]
}

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(CONTENTDIR, 'templates/'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.template.context_processors.request',
                'django.contrib.messages.context_processors.messages',
                'Instanssi.common.context_processors.short_language_code',
                'Instanssi.common.context_processors.google_settings',
                'social.apps.django_app.context_processors.backends',
                'social.apps.django_app.context_processors.login_redirect',
            ],
        },
    },
]

DEFAULT_FILE_STORAGE = 'Instanssi.common.storage.ASCIIFileSystemStorage'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

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',
    'Instanssi.common.http.Http403Middleware',
]

ROOT_URLCONF = 'Instanssi.urls'

INSTALLED_APPS = (
    'Instanssi.base_layout',
    'Instanssi.arkisto',
    'Instanssi.main2012',
    'Instanssi.main2013',
    'Instanssi.main2014',
    'Instanssi.main2015',
    'Instanssi.main2016',
    'Instanssi.main2017',
    'Instanssi.admin_base',
    'Instanssi.admin_arkisto',
    'Instanssi.admin_blog',
    'Instanssi.admin_upload',
    'Instanssi.admin_slides',
    'Instanssi.admin_events',
    'Instanssi.admin_kompomaatti',
    'Instanssi.admin_users',
    'Instanssi.admin_profile',
    'Instanssi.admin_programme',
    'Instanssi.admin_events_overview',
    'Instanssi.admin_utils',
    'Instanssi.admin_screenshow',
    'Instanssi.admin_store',
    'Instanssi.users',
    'Instanssi.kompomaatti',
    'Instanssi.ext_blog',
    'Instanssi.ext_programme',
    'Instanssi.screenshow',
    'Instanssi.dblog',
    'Instanssi.json_api',
    'Instanssi.store',
    'Instanssi.infodesk',
    'imagekit',
    'rest_framework',
    'oauth2_provider',
    'twitter_tag',
    'crispy_forms',
    'social.apps.django_app.default',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'formtools',
    'compressor',
)

# Authentication backends, notice the openid backend here.
AUTHENTICATION_BACKENDS = (
    'social.backends.open_id.OpenIdAuth',
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.google.GoogleOAuth2',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.github.GithubOAuth2',
    'social.backends.battlenet.BattleNetOAuth2',
    'social.backends.steam.SteamOpenId',
    'django.contrib.auth.backends.ModelBackend',
)


def enable_api_session_access():
    """
    This is for enabling debug mode, easier access for rest API testing
    :return:
    """
    REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'].append('rest_framework.authentication.SessionAuthentication')
    REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = ['rest_framework.permissions.AllowAny']
    REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'].append('rest_framework.renderers.BrowsableAPIRenderer')
    REST_FRAMEWORK['DEFAULT_PARSER_CLASSES'].append('rest_framework.parsers.FormParser')
    REST_FRAMEWORK['DEFAULT_PARSER_CLASSES'].append('rest_framework.parsers.MultiPartParser')


def make_cache_conf(debug_mode):
    if debug_mode:
        return {
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                'LOCATION': 'unique-snowflake'
            }
        }
    else:
        return {
            'default': {
{'fraction_non_alphanumeric': 0.1272955298754815, 'fraction_numerical': 0.006987368986831497, 'mean_word_length': 3.3037779491133383, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1430540', 'n_tokens_mistral': 3777, 'n_tokens_neox': 3664, 'n_words': 396}