# -*- 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
    'pootle.middleware.auth.AuthenticationMiddleware',
    #: Allows a user’s sessions to be invalidated when their password changes
    #: This can be removed in Django 1.10 as this feature will be enabled by
    #: default
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    #: 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',
    'django.contrib.messages.middleware.MessageMiddleware',
]


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        '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.request',
                'django.template.context_processors.static',
                'pootle_misc.context_processors.pootle_context',
                'django.contrib.messages.context_processors.messages',
            ],
            # .filesystem.Loader is enabled to allow easy customisation
            # with custom templates. See TEMPLATES[0] in 90-local.conf.template
            'loaders': [
                #: Must be before .app_directories.Loader
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ],
        },
    },
]


# 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.core',
    'pootle_app',
    'pootle_comment',
    'pootle_config',
    '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 = [
    'allauth.account.auth_backends.AuthenticationBackend',
]

ROOT_URLCONF = 'pootle.urls'

AUTH_USER_MODEL = 'accounts.User'

COMMENTS_APP = "pootle_comment"

POOTLE_EXPORT_VIEW_LIMIT = 10000
