"""
Django settings for app project.

Generated by 'django-admin startproject' using Django 1.10.2.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'hbsg^wt*6!!7b+1z9+pxj9*!h+&=g802hbad7i7+ho4$fu^rg3'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',

    'blog',
    'last_seen',
    'user_profile',

    'allauth',
    'allauth.account',
    'debug_toolbar',
    'mailer',
    'timezone_field',
    'easy_thumbnails',
    'django_cleanup',
    'crispy_forms',
#    'actstream',
    'guardian',
]

ANONYMOUS_USER_NAME = 'an0n'

TASTYPIE_DEFAULT_FORMATS = ['json', 'yaml']

SITE_ID = 1

EMAIL_BACKEND = "mailer.backend.DbBackend"

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',

    'debug_toolbar.middleware.DebugToolbarMiddleware',
    'last_seen.middleware.LastSeenMiddleware',
    'user_profile.middleware.TimezoneMiddleware',
]

ROOT_URLCONF = 'app.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'app/templates'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'app.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
    'guardian.backends.ObjectPermissionBackend',
)

ACCOUNT_SESSION_REMEMBER = True

ACCOUNT_ADAPTER = 'user_profile.users_adapter.JasnAdapter'

LAST_SEEN_INTERVAL = 60 * 1

# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'ru-ru'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

ACCOUNT_USER_DISPLAY = "user_profile.helper.get_full_name_or_username"

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
LOGIN_URL = '/login/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'app/static'),
]

THUMBNAIL_ALIASES = {
    '': {
        'profile': {'size': (170, 170), 'crop': True},
        'list': {'size': (100, 100), 'crop': True},
        'small': {'size': (60, 60), 'crop': True},
        'micro': {'size': (20, 20), 'crop': True},
        '600': {'size': (600, 600), 'crop': False},
        '400': {'size': (400, 400), 'crop': False},
        '200': {'size': (200, 200), 'crop': False},
    },
}

CRISPY_TEMPLATE_PACK = "pure_form"

try:
    from app.local_settings import *
except Exception as e:
    import sys
    import warnings
    warnings.warn("Unable import local settings [%s]: %s" % (type(e),  e))
    sys.exit(1)