"""
Django settings for citizenline project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from multisite import SiteID

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv(
    "DJANGO_SECRET_KEY", "%of1xgdp+8s&b7g+dmr^9=0b!rlg5)imp_$wx8lig-*u%pzq33"
)

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ADMINS = [("Gerhard Messelink", "admin@gmic.nl")]

WWW_HOST = "www.citizenline.local"
ALLOWED_HOSTS = ["localhost", ".citizenline.nl", ".citizenline.local"]

SITE_ID = SiteID(default=1)

# Application definition

INSTALLED_APPS = (
    "citizenline",
    "bettertexts",
    "email_registration",
    "bootstrap3",
    "bootstrap_admin",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "django_extensions",
    "django.contrib.sites",
    "ckeditor",
    "star_ratings",
    "django_comments",
    "compressor",
    "multisite",
    "accounts",
    "adminsortable2",
)

MIDDLEWARE = [
    "citizenline.middleware.SetRemoteAddrFromForwardedFor",
    "multisite.middleware.CookieDomainMiddleware",
    "multisite.middleware.DynamicSiteMiddleware",
    "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",
]

ROOT_URLCONF = "citizenline.urls"

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
                # list if you haven't customized them:
                "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",
                "django.template.context_processors.tz",
                "django.contrib.messages.context_processors.messages",
            ]
        },
    }
]

WSGI_APPLICATION = "citizenline.wsgi.application"


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

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql_psycopg2",
        "NAME": os.getenv("DATABASE_NAME", "citizenline"),
        "USER": os.getenv("DATABASE_USER", "citizenline"),
        "PASSWORD": os.getenv("DATABASE_PASSWORD", "citizenline"),
        "HOST": os.getenv("DATABASE_HOST", "localhost"),
        "PORT": os.getenv("DATABASE_PORT", "5432"),
    }
}


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

LANGUAGE_CODE = "nl-nl"

TIME_ZONE = "Europe/Amsterdam"

USE_I18N = True

USE_L10N = True

USE_TZ = True

LOCALE_PATHS = (BASE_DIR + "/bettertexts/locale",)

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

STATIC_ROOT = os.getenv("STATIC_ROOT", os.path.join(BASE_DIR, "collected_static"))

STATIC_URL = "/static/"

# Additional locations of static files.
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    "compressor.finders.CompressorFinder",
)


# Media files.

MEDIA_ROOT = os.getenv("MEDIA_ROOT", os.path.join(BASE_DIR, "media"))

MEDIA_URL = "/media/"

# Email settings.

EMAIL_HOST = os.getenv("EMAIL_HOST", "localhost")
EMAIL_PORT = os.getenv("EMAIL_PORT", 587)
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_USE_TLS = True

DEFAULT_FROM_EMAIL = "Info <info@citizenline.nl>"
SERVER_EMAIL = "Alerts <alerts@citizenline.nl>"

ADMINS = (("Admin", "admin@citizenline.nl"),)

CKEDITOR_ALLOW_NONIMAGE_FILES = False
CKEDITOR_CONFIGS = {"default": {"toolbar": "full", "height": "auto", "width": "auto"}}

BOOTSTRAP_ADMIN_SIDEBAR_MENU = True

# 3rd-party apps tracking IDs.
GOOGLE_ANALYTICS_TRACKING_ID = os.getenv("GOOGLE_ANALYTICS_TRACKING_ID")
STAR_RATINGS_RANGE = 10

COMMENTS_APP = "bettertexts"
COMMENTS_HIDE_REMOVED = False
