adm18/ntuh/ntuh/settings.py

424 lines
14 KiB
Python
Executable file

# -*- coding: utf-8 -*-
"""
Django settings for ntuh project.
Generated by 'django-admin startproject' using Django 1.8.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Full filesystem path to the project.
#PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Name of the directory for the project.
#PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1]
DEBUG = False
# DEBUG = True
# TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'dev': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# 'NAME': 'ntuh_2014', # Or path to database file if using sqlite3.
'NAME': 'adm15_dev', # Or path to database file if using sqlite3.
'USER': 'ntuh', # Not used with sqlite3.
'PASSWORD': 'n122119493', # Not used with sqlite3.
# 'HOST': 'virtualmin.ntuh.net', # Set to empty string for localhost. Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'STORAGE_ENGINE': 'INNODB',
},
'adm15.ntuh.net': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'adm15', # Or path to database file if using sqlite3.
'USER': 'ntuh', # Not used with sqlite3.
'PASSWORD': 'n122119493', # Not used with sqlite3.
# 'USER': 'root', # Not used with sqlite3.
# 'PASSWORD': "'n122119493", # Not used with sqlite3.
# 'HOST': 'virtualmin.ntuh.net', # Set to empty string for localhost. Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'STORAGE_ENGINE': 'INNODB',
# 'STORAGE_ENGINE': 'MyISAM / INNODB / ETC',
'OPTIONS': {
'charset': 'utf8mb4',
},
},
'hch.ntuh.net': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'hch', # Or path to database file if using sqlite3.
'USER': 'ntuh', # Not used with sqlite3.
'PASSWORD': 'n122119493', # Not used with sqlite3.
# 'USER': 'root', # Not used with sqlite3.
# 'PASSWORD': "'n122119493", # Not used with sqlite3.
# 'HOST': 'virtualmin.ntuh.net', # Set to empty string for localhost. Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'STORAGE_ENGINE': 'INNODB',
# 'STORAGE_ENGINE': 'MyISAM / INNODB / ETC',
},
'plastic15.ntuh.net': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'plastic15', # Or path to database file if using sqlite3.
'USER': 'ntuh', # Not used with sqlite3.
'PASSWORD': 'n122119493', # Not used with sqlite3.
# 'HOST': 'virtualmin.ntuh.net', # Set to empty string for localhost. Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'STORAGE_ENGINE': 'INNODB',
},
'ck': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'cks', # Or path to database file if using sqlite3.
'USER': 'cks', # Not used with sqlite3.
'PASSWORD': 'cks63080', # Not used with sqlite3.
# 'HOST': 'virtualmin.ntuh.net', # Set to empty string for localhost. Not used with sqlite3.
# 'HOST': 'cks.xiao.tw',
'HOST': '192.168.10.50',
'PORT': '', # Set to empty string for default. Not used with sqlite3.
},
}
if 'adm15.ntuh.net' in BASE_DIR or 'adm18.ntuh.net' in BASE_DIR:
NOADS=False
DATABASES['default'] = DATABASES['adm15.ntuh.net']
SPECIALTY = '神經外科'
elif 'hch.ntuh.net' in BASE_DIR:
NOADS=False
DATABASES['default'] = DATABASES['hch.ntuh.net']
SPECIALTY = '新竹分院'
elif 'plastic15.ntuh.net' in BASE_DIR:
NOADS=False
DATABASES['default'] = DATABASES['plastic15.ntuh.net']
SPECIALTY = '整形外科'
else:
NOADS=False
DATABASES['default'] = DATABASES['dev']
SPECIALTY = 'Development'
# print SPECIALTY
# 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.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
#TIME_ZONE = 'America/Chicago'
TIME_ZONE = 'Asia/Taipei'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
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
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/').replace('\\','/')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
MEDIA_URL = '/site_media/'
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic/').replace('\\','/')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
#ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
# '/home/xfr/Titanium Studio Workspace/xfr/ntuh/static',
# '/home/xfr/workspace/ntuh/static',
# '/home/ntuh/domains/adm.ntuh.net/ntuh/static',
# os.path.join(BASE_DIR, 'static').replace('\\','/'),
)
# 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',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 't+%(@3c&54hu+9)@!-=i3c@+b4+b#94un3p1k@8!!j4zjz8_sw'
# # List of callables that know how to import templates from various sources.
# TEMPLATE_LOADERS = (
# 'django.template.loaders.filesystem.Loader',
# 'django.template.loaders.app_directories.Loader',
# # 'django.template.loaders.eggs.Loader',
# )
MIDDLEWARE = [
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
]
ROOT_URLCONF = 'ntuh.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.
# '/home/xfr/workspace/ntuh/fileupload/templates',
# '/home/xfr/Titanium Studio Workspace/xfr/ntuh/templates',
# '/home/xfr/workspace/ntuh/templates',
# # '/home/ntuh/domains/adm.ntuh.net/ntuh/templates',
# os.path.join(BASE_DIR, 'templates').replace('\\','/'),
# # '/usr/local/lib/python2.7/dist-packages/photologue/templates',
# )
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'django.contrib.admin',
'django.contrib.admindocs',
"categories",
"categories.editor",
'debug_toolbar',
'haystack',
# 'south',
'registry',
'ck',
# 'sorl.thumbnail',
# 'multiuploader',
# 'imagekit',
# 'uploadify',
'fileupload',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'filters': {
'special': {
# '()': 'project.logging.SpecialFilter',
'foo': 'bar',
}
},
'handlers': {
'null': {
'level': 'DEBUG',
# 'class': 'django.utils.log.NullHandler',
'class': 'logging.NullHandler',
},
'console':{
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'filters': ['special']
}
},
'loggers': {
'django': {
'handlers': ['null','console'],
'propagate': True,
'level': 'INFO',
},
'django.request': {
# 'handlers': ['mail_admins'],
'handlers': ['console'],
'level': 'ERROR',
'propagate': False,
},
'myproject.custom': {
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
'filters': ['special']
}
}
}
SESSION_COOKIE_AGE = 60*60
INTERNAL_IPS = (
'127.0.0.1',
'192.168.11.175',
'192.168.10.100'
# '172.17.11.0/24',
)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
# TEMPLATE_CONTEXT_PROCESSORS=('django.contrib.auth.context_processors.auth',
# 'django.core.context_processors.debug',
# 'django.core.context_processors.i18n',
# 'django.core.context_processors.media',
# 'django.core.context_processors.static',
# 'django.core.context_processors.tz',
# 'django.contrib.messages.context_processors.messages',
# # 'ntuh.context_processors.context_processors',
# 'context_processors.context_processors',
# )
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
'/home/xfr/workspace/ntuh/fileupload/templates',
'/home/xfr/Titanium Studio Workspace/xfr/ntuh/templates',
'/home/xfr/workspace/ntuh/templates',
# '/home/ntuh/domains/adm.ntuh.net/ntuh/templates',
os.path.join(BASE_DIR, 'templates').replace('\\','/'),
],
'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',
],
},
},
]
ALLOWED_HOSTS = [
'dev.xiao.tw',
'dev18',
'virtualmin.ntuh.net',
'localhost',
'192.168.11.178',
'192.168.10.10',
'192.168.26.10',
]
DEFAULT_AUTO_FIELD='django.db.models.AutoField'
########## HAYSTACK
# HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
# },
# }
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}
HAYSTACK_ITERATOR_LOAD_PER_QUERY = 1000
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
CSRF_TRUSTED_ORIGINS = ['https://*.ntuh.net','https://*.127.0.0.1']