# Django settings for maplepepper_com project.
import os
import sys
import warnings

warnings.simplefilter("ignore")

## Directories
PROJECT_ROOT = os.path.dirname(os.path.realpath(os.path.dirname(__file__)))
SITE_ROOT = os.path.dirname(PROJECT_ROOT)
# MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media/')
MEDIA_ROOT = "/var/lib/django/pbp_com/media/"
VIRTUALENV = "/var/lib/virtualenvs/pbp/lib/python2.5/site-packages"
ADMIN_TOOLS_MENU = "pbp_com.menu.CustomMenu"

sys.path.append(SITE_ROOT)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

# Django settings for pbp project.
ADMINS = (("Jeremiah Savage", "jeremiahs@pbp.me"),)

LANGUAGE_CODE = "en-us"
MANAGERS = ADMINS
USE_I18N = True
SEND_BROKEN_LINK_EMAILS = False

TIME_ZONE = "America/New_York"
LANGUAGE_CODE = "en-us"
SITE_ID = 5  # ia.com

import logging

LOG_DATE_FORMAT = "%d %b %Y %H:%M:%S"
LOG_FORMATTER = logging.Formatter(
    "%(asctime)s %(name)-7s: %(levelname)-8s %(message)s", datefmt=LOG_DATE_FORMAT
)

FILE_HANDLER = logging.FileHandler(os.path.join("/var/log/django/") + "cp_com.log", "w")
CONSOLE_HANDLER = logging.StreamHandler()  # defaults to stderr
CONSOLE_HANDLER.setFormatter(LOG_FORMATTER)
CONSOLE_HANDLER.setLevel(logging.DEBUG)

AUTH_PROFILE_MODULE = "profiles.UserProfile"

LOGIN_REDIRECT_URL = "/"

AGENTS_EXCLUSION_FILE = MEDIA_ROOT + "allagents.xml"

SECRET_KEY = "l(4_rf+z#5oj7ik0j$ax9+zl)3yfkh8-ige$=!eoq=hydfbm7k"


TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.request",
    "django.core.context_processors.debug",
    "django.core.context_processors.media",
    "django.contrib.messages.context_processors.messages",
    "adzone.context_processors.get_source_ip",
)

MIDDLEWARE_CLASSES = (
    "django.middleware.cache.UpdateCacheMiddleware",
    "django.middleware.common.CommonMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "debug_toolbar.middleware.DebugToolbarMiddleware",
    "ipfilter.middleware.FilterIPs",
    "django.middleware.csrf.CsrfViewMiddleware",
    "django.middleware.cache.FetchFromCacheMiddleware",
)

CACHE_MIDDLEWARE_ALIAS = "default"
CACHE_MIDDLEWARE_SECONDS = 10400
CACHE_MIDDLEWARE_KEY_PREFIX = "cp_"

AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",)

ROOT_URLCONF = "urls.cp"
MARKITUP_FILTER = ("django.contrib.markup.templatetags.markup.textile", {})
MARKITUP_SET = "markitup/sets/markdown"
HAYSTACK_SITECONF = "pbp_com.search_sites"
HAYSTACK_SEARCH_ENGINE = "whoosh"
# HAYSTACK_WHOOSH_PATH=os.path.join(PROJECT_ROOT, 'search-index')


INSTALLED_APPS = (
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.admin",
    "django.contrib.markup",
    "django.contrib.humanize",
    "django.contrib.comments",
    "django.contrib.admindocs",
    "django.contrib.sitemaps",
    "django.contrib.flatpages",
    "django_extensions",
    "registration",
    "profiles",
    "debug_toolbar",
    "typogrify",
    "taggit",
    "django_inlines",
    "django_wysiwyg",
    "markitup",
    "convert",
    "ipfilter",
    "documents",
    "directory",
    "newsroom",
    "darkroom",
    "adzone",
    "remember",
    "almanac",
)
