#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Pootle project-level configuration settings."""


MIDDLEWARE_CLASSES = [
    #: Resolves paths
    'pootle.middleware.baseurl.BaseUrlMiddleware',
    #: Must be as high as possible (see above)
    'django.middleware.cache.UpdateCacheMiddleware',
    #: Avoids caching for authenticated users
    'pootle.middleware.cache.CacheAnonymousOnly',
    #: Protect against clickjacking and numerous xss attack techniques
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    #: Support for e-tag
    'django.middleware.http.ConditionalGetMiddleware',
    #: Protection against cross-site request forgery
    'django.middleware.csrf.CsrfViewMiddleware',
    #: Must be before authentication
    'django.contrib.sessions.middleware.SessionMiddleware',
    #: Must be before anything user-related
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    #: User-related
    'django.middleware.locale.LocaleMiddleware',
    #: Sets Python's locale based on request's locale for sorting, etc.
    'pootle.middleware.setlocale.SetLocale',
    #: Nice 500 and 403 pages (must be after locale to have translated versions)
    'pootle.middleware.errorpages.ErrorPagesMiddleware',
    'django.middleware.common.CommonMiddleware',
    #: Must be early in the response cycle (close to bottom)
    'pootle.middleware.captcha.CaptchaMiddleware',
    #: Must be last in the request cycle (at the bottom)
    'django.middleware.cache.FetchFromCacheMiddleware',
]

TEMPLATE_CONTEXT_PROCESSORS = [
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request",
    "django.core.context_processors.static",
    "pootle_misc.context_processors.pootle_context",
]


# Same as defaults but with AssetsFinder
STATICFILES_FINDERS = (
    "django_assets.finders.AssetsFinder",
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder"
)


INSTALLED_APPS = [
    'django.contrib.sessions',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.humanize',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    # Pootle-specific
    'accounts',
    'contact',
    'import_export',  # Put before 'pootle' to ensure overextends works.
    'pootle',
    'pootle_app',
    'pootle_misc',
    'pootle_store',
    'pootle_language',
    'pootle_project',
    'pootle_translationproject',
    'pootle_profile',
    'pootle_statistics',
    'pootle_terminology',
    'reports',
    'staticpages',
    'virtualfolder',
    # External apps
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'django_assets',
    'django_rq',
    'overextends',
]


AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
]

ROOT_URLCONF = 'pootle.urls'

AUTH_USER_MODEL = 'accounts.User'
