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

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


MIDDLEWARE_CLASSES = [
    #: Resolves paths
    'pootle_misc.middleware.baseurl.BaseUrlMiddleware',
    #: Needs to be before anything that writes to the db
    'django.middleware.transaction.TransactionMiddleware',
    #: Must be early to detect the need to install or update schema,
    #: but must precede the cache middleware
    'pootle_misc.middleware.siteconfig.SiteConfigMiddleware',
    #: Must be as high as possible (see above)
    'django.middleware.cache.UpdateCacheMiddleware',
    #: Support for e-tag
    'django.middleware.http.ConditionalGetMiddleware',
    #: Compress responses
    'django.middleware.gzip.GZipMiddleware',
    #: Protection against cross-site request forgery
    'django.middleware.csrf.CsrfViewMiddleware',
    #: Must be before authentication and MessageMiddleware
    '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',
    #: Messages framework
    'django.contrib.messages.middleware.MessageMiddleware',
    #: Nice 500 and 403 pages (must be after locale to have translated versions)
    'pootle_misc.middleware.errorpages.ErrorPagesMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'pootle.middleware.check_cookies.CheckCookieMiddleware',
    #: 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.contrib.messages.context_processors.messages",
    "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",
]


TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or
    # "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    working_path('templates/custom'),
    working_path('templates'),
)


# 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.sites',
    'django.contrib.admin',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Pootle-specific
    'pootle_app',
    'pootle_misc',
    'pootle_store',
    'pootle_language',
    'pootle_project',
    'pootle_translationproject',
    'pootle_profile',
    'pootle_statistics',
    'pootle_notifications',
    'pootle_autonotices',
    'pootle_terminology',
    'legalpages',
    # External apps
    'registration',
    'profiles',
    'djblets.siteconfig',
    'djblets.util',
    'contact_form_i18n',
    'django_assets',
    'voting',
]


AUTHENTICATION_BACKENDS = [
    #: Uncomment the following line for enabling LDAP authentication
    #'pootle.auth.ldap_backend.LdapBackend',
    'django.contrib.auth.backends.ModelBackend',
]

ROOT_URLCONF = 'pootle.urls'

AUTH_PROFILE_MODULE = "pootle_profile.PootleProfile"
