# Django settings for smaoahpa project.
import os.path
import sys

os.environ['PYTHON_EGG_CACHE'] = '/tmp'
# os.environ['DJANGO_SETTINGS_MODULE'] = 'smaoahpa.settings'

# WSGI stuff
# import django.core.handlers.wsgi
# application = django.core.handlers.wsgi.WSGIHandler()

# Confirm this is in path.
# path = '/home/smaoahpa/smaoahpa'
# if path not in sys.path:
#    sys.path.append(path)

# This flag triggers now the URL patterns in url.py file.
# The production_setting.py is triggered now by os name.
DEV = False

# This flag triggers the settings on victorio for production in production_settings.py
# or development (feeding the db, syncdb, etc.)
# IMPORTANT: Do NOT svn ci the development settings file!

VDEV = True

# Cip's local config er different than Ryan's one

LCIP = False

# I prefer to use things like this because then settings don't need to depend on absolute paths all the time.
# Can just list the media or template dirs as here('templates') instead of '/home/me/.../smaoahpa/templates/

here = lambda x: os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), x)
here_cross = lambda x: os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), *x) 

DEBUG = True
TEMPLATE_DEBUG = DEBUG
# just testing svn
ADMINS = (
	('Ciprian Gerstenberger', 'ciprian.gerstenberger@uit.no'),
	('Trond Trosterud', 'trond.trosterud@uit.no'),
	('Lene Antonsen', 'lene.antonsen@uit.no'),
	('Ryan Johnson', 'rjo040@post.uit.no'),
)

MANAGERS = ADMINS

# This is overridden below if the hostname is right.

DATABASE_ENGINE = 'sqlite3'		   # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = here('test.db')			 # Or path to database file if using sqlite3.
# DATABASE_NAME = '/home/smaoahpa/smaoahpa/test.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. Not used with sqlite3.
DATABASE_PORT = ''			 # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.

TIME_ZONE = 'Europe/Oslo'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'no'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = here('media')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"

# MEDIA_URL = 'http://victorio.uit.no/smaoahpa/media/'

MEDIA_URL = '/media/'

# 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 = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '+&dhg83#u^mg$vnp^7u2xd8wo15&=_c#yf0*no-mzrej!@zdw_'

# 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',
#	 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
	'django.middleware.common.CommonMiddleware',
	'django.contrib.sessions.middleware.SessionMiddleware',
	'django.middleware.locale.LocaleMiddleware',
	'django.contrib.auth.middleware.AuthenticationMiddleware',
	'django.middleware.doc.XViewMiddleware',
	# 'smaoahpa.courses.middleware.GradingMiddleware',
 	# 'smaoahpa.management.middlewares.SQLLogToConsoleMiddleware',
)

ROOT_URLCONF = 'smaoahpa.urls'

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.
	os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'),
	# os.path.join(os.path.dirname(__file__), 'drills/templates').replace('\\','/'),
)

TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth",
				"django.core.context_processors.debug",
				"django.core.context_processors.i18n",
				"django.core.context_processors.media",
				"django.core.context_processors.request",
				"courses.context_processors.request_user",)
#				"management.context_processors.admin_media_prefix")


INSTALLED_APPS = (
	'django.contrib.auth',
	'django.contrib.contenttypes',
	'django.contrib.sessions',
	'django.contrib.sites',
	'django.contrib.admin',
	'drills',
	'courses',
)

LANGUAGES = (
	('sma', 'South Sami'),
	('no', 'Norwegian'),
	('swe', 'Swedish'),
	('en', 'English'),
	('de', 'German'),
)

# # # 
#
# Some settings for the install.py scripts
#
# # # 

# maybe some of these actually should be options in the install script... 

MAIN_LANGUAGE = ('sma', 'South Sami')
LOOKUP_TOOL = '/usr/local/bin/lookup'
FST_DIRECTORY = '%s/gt/sma/bin' % os.environ.get('GTHOME')


# #
#
# LOGGING
#
# #

# TODO: logging!
# http://docs.djangoproject.com/en/dev/topics/logging/

if os.uname()[1] == 'victorio.uit.no':
	try:
		if VDEV:
			from x_settings import *
		else:
			from production_settings import *
	except:
		print "Could not load production_settings.py"
		sys.exit()

if LCIP:
	try:
		from cip_settings import *
	except:
		print "Could not load cip_settings.py"
		sys.exit()


# #
#
# USER PROFILES
#
# #

AUTH_PROFILE_MODULE = 'courses.UserProfile'
LOGIN_REDIRECT_URL = '/smaoahpa/courses/'
LOGIN_URL = '/smaoahpa/courses/login/'

