# Django settings for pycon project.
import os
from urllib import pathname2url
#from bebop.config.base import app_configs_from_global_settings

## help do development on multiple machines dynamicly
DEV_INSTALL_ROOT = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
if os.sep != '/': DEV_INSTALL_ROOT = DEV_INSTALL_ROOT.replace(os.sep, '/')

DEBUG = True
TEMPLATE_DEBUG = True
#TEMPLATE_STRING_IF_INVALID = '[TEMPLATE_ERROR]'

CONFERENCE_NAME = 'PyCon 2009'
DATE_FORMAT = "D, j M Y H:i:s O"

USE_ETAGS = True

ADMINS = (
    ('admin', 'your_email@domain.com'),
)

MANAGERS = ADMINS
DEFAULT_FROM_EMAIL =     ''
USERMGR_FROM_EMAIL =     ''
USERMGR_REPLYTO_EMAIL =  ''
PROPMGR_FROM_EMAIL =     ''
PROPMGR_REPLYTO_EMAIL =  ''
MAILER_FROM_EMAIL =      ''
MAILER_REPLY_TO_EMAIL =  ''

SCHEDULE_CHAIR_NOTIFY = ()

PROPMGR_STATS_EMAIL_TO = []


DATABASE_ENGINE = 'sqlite3'     # or: 'mysql', 'sqlite3', 'ado_mssql'.
DATABASE_NAME = 'testing.db'    # Or path to database file if using sqlite3.
DATABASE_USER = ''              # Not used with sqlite3.
DATABASE_PASSWORD = ''          # Not used with sqlite3.
DATABASE_HOST = ''              # Set to empty string for localhost.
DATABASE_PORT = ''              # Set to empty string for default.

if 'USE_POSTGRESQL' in os.environ:
    # override for testing with postgresql to match the server install
    # good for testing app rollouts on live data but in a test environment
    DATABASE_ENGINE = 'postgresql_psycopg2'
    DATABASE_NAME = 'testing09'
    DATABASE_USER = 'pycon-tech'
    DATABASE_PASSWORD = 'testing09'
    DATABASE_HOST = 'localhost'
    DATABASE_PORT = '5432'

#DEFAULT_CHARSET defaults to utf8 which is what we want.
DEFAULT_EMAIL_CHARSET = 'ascii' # custom pycon extension.
#DEFAULT_EMAIL_CHARSET = 'utf8' # custom pycon extension.

# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/current/static/datetime-keywords.html
#                                                  #DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

SESSION_COOKIE_NAME = 'pycon2009_session_dev'

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = DEV_INSTALL_ROOT + '/common/'

RELEASE_FORM_PATH = MEDIA_ROOT + 'talkdata/PyCon2009/Releases/'

PROPOSAL_UPLOAD_TO = 'talkdata/2009/public/'
EVENT_UPLOAD_TO = 'talkdata/PyCon2009/'
SPONSORSHIP_UPLOAD_TO = 'talkdata/sponsors'

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = '/common/2009/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
#ADMIN_MEDIA_PREFIX = 'file:' + pathname2url(DEV_INSTALL_ROOT + '/django/contrib/admin/media/')
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '!ph!d^%to@m78h@2z*te7yy*2&u!(!csq+5&8$$aje!afkrkdk'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
)

MIDDLEWARE_CLASSES = (
    ##"django.middleware.cache.CacheMiddleware", ## breaks tooo much
    'pycon.middleware.xstats.XStatsMiddleware', ## requires features app
    'django.middleware.gzip.GZipMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'django.middleware.http.ConditionalGetMiddleware', ## Causing cookie problems?
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'django.middleware.transaction.TransactionMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.core.context_processors.auth",
    "django.core.context_processors.debug",
    #"django.core.context_processors.i18n",
    "pycon.core.context_processors.request",
    "pycon.core.context_processors.settings",
    "pycon.navbar.context_processors.crumbs",
    #"pycon.navbar.context_processors.navtree",
    "pycon.navbar.context_processors.navbars",
)

ROOT_URL     = '/2009/'
LOGIN_URL    = ROOT_URL + 'login/'
LOGOUT_URL   = ROOT_URL + 'logout/'
ADMIN_URL    = ROOT_URL + 'admin/'
PROFILE_URL  = ROOT_URL + 'profile/'
OPTIONS_URL  = ROOT_URL + 'options/'
ROOT_URLCONF = 'pycon.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates".
    # Always use forward slashes, even on Windows.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.flatpages',
    'django.contrib.humanize',
    #'django.contrib.webdesign',
    'tagging',
    'website',
    'pycon',
    'pycon.navbar',
    'pycon.feedutil',
    'pycon.restructuredtext',
    'pycon.features',
    'pycon.usermgr',
    'pycon.survey',
#    'pycon.mailer',
    #'pycon.badges',
    'pycon.sponsorship',
    'pycon.cachemgr',
    #'jobboard',
    'django.contrib.admin',
)

#ABSOLUTE_URL_OVERRIDES = {
#    'propmgr.proposal': # sync with urls.py
#        lambda o: "%sconference/proposals/%d/" % (ROOT_URL, o.id),
#}

class NullStream(object):
    def write(*args, **kwdargs): pass
    writeline = write
    writelines = write

RESTRUCTUREDTEXT_FILTER_SETTINGS = { 'cloak_email_addresses': True,
                                     'file_insertion_enabled': False,
                                     'raw_enabled': False,
                                     'warning_stream': NullStream(),
                                     'strip_comments': True,}

FORCE_LOWERCASE_TAGS = True

AUTH_PROFILE_MODULE = "usermgr.UserProfile"

SCHEDULE_COOKIE_MAX_AGE = 60*60*24*31*3 ## 3 months (about)

NAVBAR_TREE_MAX_DEPTH = 3
NAVBAR_TREE_SHOW_DEPTH = 0
NAVBAR_TREE_MARK_SELECTED = True

CACHE_BACKEND = "locmem:///?max_entries=3000"
#CACHE_MIDDLEWARE_SECONDS = 300
#MAX_DURATION = 180

## This is assigned to http://localhost:8000/apps/maps/
GOOGLE_MAPS_KEY=("ABQIAAAA72mjocDxVHMiQWCb2hiCsRQQRSxhr_qtwum"
                 "GHA9HeT4IsKdxChQis_m8tp1kejuLVHdWhBX0w7SHIA")

GOOGLE_SEARCH_KEY="012663505664874652253:gefcynhzofi"


#PAYPAL_LOGIN   = "JatDayraps"
#PAYPAL_PARTNER = "VeriSign"
#PAYPAL_URL     = "https://payflowlink.paypal.com"

#app_configs_from_global_settings(globals())
