aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2013-05-11 00:03:50 +0200
committerTheo Chatzimichos <tampakrap@gentoo.org>2013-05-11 00:03:50 +0200
commit6d96dec1f7336060493a7c4763884f72e55c1ed6 (patch)
tree32c6f72fc5596d5d7500667dd388bed77292d94b /okupy/settings
parentaccounts/urls.py will be rewritten as well (diff)
downloadidentity.gentoo.org-6d96dec1f7336060493a7c4763884f72e55c1ed6.tar.gz
identity.gentoo.org-6d96dec1f7336060493a7c4763884f72e55c1ed6.tar.bz2
identity.gentoo.org-6d96dec1f7336060493a7c4763884f72e55c1ed6.zip
Move stuff from identity to okupy
Diffstat (limited to 'okupy/settings')
-rw-r--r--okupy/settings/__init__.py95
-rw-r--r--okupy/settings/development.py.sample115
-rw-r--r--okupy/settings/local_settings.py.sample75
-rw-r--r--okupy/settings/production.py116
4 files changed, 401 insertions, 0 deletions
diff --git a/okupy/settings/__init__.py b/okupy/settings/__init__.py
new file mode 100644
index 0000000..bfacc04
--- /dev/null
+++ b/okupy/settings/__init__.py
@@ -0,0 +1,95 @@
+# -*- coding: utf-8 -*-
+
+# Django settings for okupy project.
+
+from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
+import os
+
+# Full path of the project dir
+PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) + '/../..'
+
+try:
+ from local_settings import *
+except ImportError:
+ raise Exception('No local_settings.py found, please copy local_settings.py.sample and edit it accordingly')
+
+if DEVELOPMENT:
+ try:
+ from development import *
+ except ImportError:
+ raise Exception('No development.py found, please copy development.py.sample and edit it accordingly if needed')
+else:
+ from production import *
+
+MANAGERS = ADMINS
+
+SITE_ID = 1
+
+ROOT_URLCONF = 'okupy.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'okupy.wsgi.application'
+
+# 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 when DEBUG=False.
+# 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,
+ 'formatters':{
+ 'okupy': {
+ 'format': '%(instance_name)s: %(levelname)s %(id_name)s %(client_ip)s Message: %(message)s File: %(module)s Function: %(funcName)s Line: %(lineno)d',
+ },
+ },
+ 'filters': {
+ 'require_debug_false': {
+ '()': 'django.utils.log.RequireDebugFalse'
+ }
+ },
+ 'handlers': {
+ 'mail_admins': {
+ 'level': 'ERROR',
+ 'filters': ['require_debug_false'],
+ 'class': 'django.utils.log.AdminEmailHandler',
+ 'include_html': True,
+ },
+ 'console': {
+ 'level': 'DEBUG',
+ 'class': 'logging.StreamHandler',
+ 'formatter': 'okupy',
+ },
+ 'syslog': {
+ 'level': 'INFO',
+ 'class': 'logging.handlers.SysLogHandler',
+ 'formatter': 'okupy',
+ 'address': '/dev/log',
+ },
+ },
+ 'loggers': {
+ 'mail_okupy': {
+ 'handlers': ['mail_admins'],
+ 'level': 'ERROR',
+ 'propagate': True,
+ },
+ 'okupy': {
+ 'handlers': ['console' if DEBUG else 'syslog'],
+ 'level': 'DEBUG' if DEBUG else 'INFO',
+ },
+ }
+}
+
+LOGIN_URL = '/login/'
+LOGIN_REDIRECT_URL = '/'
+LOGOUT_URL = '/logout/'
+SESSION_EXPIRE_AT_BROWSER_CLOSE = True
+
+# Custom authentication backend
+AUTHENTICATION_BACKENDS = (
+ 'django_auth_ldap.backend.LDAPBackend',
+)
+
+# email sending variables regarding server authentication
+# and configuration should be specified in local_settings
+EMAIL_SUBJECT_PREFIX = '[%s] ' % INSTANCE_NAME
diff --git a/okupy/settings/development.py.sample b/okupy/settings/development.py.sample
new file mode 100644
index 0000000..9d48041
--- /dev/null
+++ b/okupy/settings/development.py.sample
@@ -0,0 +1,115 @@
+# -*- coding: utf-8 -*-
+
+# Sample settings for development environment
+# Rename it to development.py and change accordingly the vars if needed
+
+from django.conf import settings
+
+# DEBUG Options: Select "True" for development use, "False" for production use
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+# Instance name, used in:
+# * prefix of the notification mails: "[${INSTANCE_NAME}] ${TITLE}"
+# * log dir name: /var/log/${INSTANCE_NAME}
+# * console logs: ${INSTANCE_NAME} ${IP} ${ERROR}
+INSTANCE_NAME = 'okupy-dev'
+
+# Hosts/domain names that are valid for this site; required if DEBUG is False
+# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = []
+
+# 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.
+# In a Windows environment this must be set to your system time zone.
+TIME_ZONE = 'UTC'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+# 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
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/var/www/example.com/media/"
+MEDIA_ROOT = settings.PROJECT_ROOT + '/media/'
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://example.com/media/", "http://media.example.com/"
+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: "/var/www/example.com/static/"
+STATIC_ROOT = settings.PROJECT_ROOT + '/static/'
+
+# URL prefix for static files.
+# Example: "http://example.com/static/", "http://static.example.com/"
+STATIC_URL = '/static/'
+
+# 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.
+ settings.PROJECT_ROOT + '/okupy/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',
+# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# 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_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ # Uncomment the next line for simple clickjacking protection:
+ # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+)
+
+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.
+ settings.PROJECT_ROOT + '/okupy/templates/'
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'django_auth_ldap',
+ 'okupy.accounts',
+)
+
+EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
+EMAIL_FILE_PATH = '/tmp/okupy/mail'
diff --git a/okupy/settings/local_settings.py.sample b/okupy/settings/local_settings.py.sample
new file mode 100644
index 0000000..34b11b4
--- /dev/null
+++ b/okupy/settings/local_settings.py.sample
@@ -0,0 +1,75 @@
+# -*- conding: utf-8 -*-
+
+# Sample configuration file for okupy project.
+# Rename it to local_settings.py and change accordingly the vars
+
+# The listed admins will receive mail notifications
+ADMINS = (
+ ('admin', 'admin@example.com'),
+)
+
+# Select "True" for development environment, "False" for production environment
+DEVELOPMENT = True
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': '', # Or path to database file if using sqlite3.
+ # The following settings are not used with sqlite3:
+ 'USER': '',
+ 'PASSWORD': '',
+ 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
+ 'PORT': '', # Set to empty string for default.
+ }
+}
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'secret'
+
+# Variables regarding email sending (host, credentials)
+# SERVER_EMAIL = 'user@localhost'
+# EMAIL_HOST = 'localhost'
+# EMAIL_PORT = '25'
+# EMAIL_HOST_USER = 'user'
+# EMAIL_HOST_PASSWORD = 'secret'
+# EMAIL_USE_TLS = False
+
+# LDAP settings
+
+import ldap
+
+AUTH_LDAP_SERVER_URI = 'ldap://ldap.example.com'
+
+AUTH_LDAP_CONNECTION_OPTIONS = {
+ ldap.OPT_REFERRALS: 0,
+ ldap.OPT_X_TLS_DEMAND: False,
+}
+
+AUTH_LDAP_BIND_DN = ''
+AUTH_LDAP_BIND_PASSWORD = ''
+
+AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=example,dc=com"
+
+AUTH_LDAP_PERMIT_EMPTY_PASSWORD = False
+
+AUTH_LDAP_START_TLS = False
+
+#AUTH_LDAP_USER_ATTR_MAP = {}
+
+#AUTH_LDAP_PROFILE_ATTR_MAP = {}
+
+#AUTH_LDAP_GROUP_SEARCH
+#AUTH_LDAP_GROUP_TYPE
+#AUTH_LDAP_REQUIRE_GROUP
+#AUTH_LDAP_DENY_GROUP
+#AUTH_LDAP_CACHE_GROUPS
+#AUTH_LDAP_GROUP_CACHE_TIMEOUT
+#AUTH_LDAP_FIND_GROUP_PERMS
+
+#AUTH_LDAP_USER_FLAGS_BY_GROUP = {
+ #'is_acive': '',
+ #'is_staff': '',
+ #'is_superuser': '',
+#}
+
+#AUTH_LDAP_PROFILE_FLAGS_BY_GROUP = {}
diff --git a/okupy/settings/production.py b/okupy/settings/production.py
new file mode 100644
index 0000000..06f5eda
--- /dev/null
+++ b/okupy/settings/production.py
@@ -0,0 +1,116 @@
+# -*- coding: utf-8 -*-
+
+# Settings for production environment
+
+from django.conf import settings
+
+# DEBUG Options: Select "True" for development use, "False" for production use
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+
+# Instance name, used in:
+# * prefix of the notification mails: "[${INSTANCE_NAME}] ${TITLE}"
+# * log dir name: /var/log/${INSTANCE_NAME}
+# * console logs: ${INSTANCE_NAME} ${IP} ${ERROR}
+INSTANCE_NAME = 'okupy'
+
+# Hosts/domain names that are valid for this site; required if DEBUG is False
+# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = []
+
+# 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.
+# In a Windows environment this must be set to your system time zone.
+TIME_ZONE = 'UTC'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = False
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = False
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/var/www/example.com/media/"
+MEDIA_ROOT = '/var/www/okupy.gentoo.org/htdocs/media/'
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://example.com/media/", "http://media.example.com/"
+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: "/var/www/example.com/static/"
+STATIC_ROOT = '/var/www/okupy.gentoo.org/htdocs/static/'
+
+# URL prefix for static files.
+# Example: "http://example.com/static/", "http://static.example.com/"
+STATIC_URL = '/static/'
+
+# 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.
+ settings.PROJECT_ROOT + '/okupy/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',
+# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# 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_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ # Uncomment the next line for simple clickjacking protection:
+ # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+)
+
+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.
+ settings.PROJECT_ROOT + '/okupy/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',
+ 'okupy.accounts',
+ 'okupy.recover',
+ 'okupy.verification',
+)