accounts: Add context_processor and middleware.
[xnet] / xnet / settings.py
CommitLineData
33234b2f
RB
1# Django settings for xnet project.
2
3DEBUG = True
4TEMPLATE_DEBUG = DEBUG
5
6import os.path
7ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
8
9def read_pass(name):
10 fname = os.path.join(ROOT_DIR, 'private', name)
11 with open(fname, 'r') as f:
12 return f.readline().strip()
13
14ADMINS = (
15 # ('Your Name', 'your_email@example.com'),
16)
17
18MANAGERS = ADMINS
19
20DATABASES = {
21 'default': {
22 'ENGINE': 'django.db.backends.sqlite3',
23 'NAME': os.path.join(ROOT_DIR, 'db.sqlite'),
24 }
25}
26
27AUTHENTICATION_BACKENDS = (
28 'django_authgroupex.auth.AuthGroupeXBackend',
29)
30AUTHGROUPEX_KEY = read_pass('authgroupex.key')
31AUTHGROUPEX_FIELDS = ('username', 'firstname', 'lastname', 'perms')
32AUTHGROUPEX_SUPERADMIN_PERMS = ('admin',)
53722fb0 33AUTHGROUPEX_USER_MODEL = 'accounts.Account'
33234b2f
RB
34LOGIN_URL = '/xorgauth/'
35LOGIN_REDIRECT_URL = '/'
36
53722fb0
BG
37AUTH_USER_MODEL = 'accounts.Account'
38
33234b2f
RB
39# Local time zone for this installation. Choices can be found here:
40# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
41# although not all choices may be available on all operating systems.
42# In a Windows environment this must be set to your system time zone.
43TIME_ZONE = 'Europe/Paris'
44
45# Language code for this installation. All choices can be found here:
46# http://www.i18nguy.com/unicode/language-identifiers.html
47LANGUAGE_CODE = 'en-us'
74a237a6
RB
48OCALE_PATHS = (
49 os.path.join(ROOT_DIR, 'locale'),
50)
51
97a0ca06
RB
52TEMPLATE_CONTEXT_PROCESSORS = (
53 'django.contrib.auth.context_processors.auth',
54 'django.core.context_processors.debug',
55 'django.core.context_processors.i18n',
56 'django.core.context_processors.media',
57 'django.core.context_processors.static',
58 'django.core.context_processors.tz',
59 'django.contrib.messages.context_processors.messages',
60 'xnet.accounts.context_processors.xnet',
61)
33234b2f
RB
62
63SITE_ID = 1
64
65# If you set this to False, Django will make some optimizations so as not
66# to load the internationalization machinery.
67USE_I18N = True
68
69# If you set this to False, Django will not format dates, numbers and
70# calendars according to the current locale.
71USE_L10N = True
72
73# If you set this to False, Django will not use timezone-aware datetimes.
74USE_TZ = True
75
76# Absolute filesystem path to the directory that will hold user-uploaded files.
77# Example: "/home/media/media.lawrence.com/media/"
626048e1 78MEDIA_ROOT = os.path.join(ROOT_DIR, 'media')
33234b2f
RB
79
80# URL that handles the media served from MEDIA_ROOT. Make sure to use a
81# trailing slash.
82# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
626048e1 83MEDIA_URL = '/media/'
33234b2f
RB
84
85# Absolute path to the directory static files should be collected to.
86# Don't put anything in this directory yourself; store your static files
87# in apps' "static/" subdirectories and in STATICFILES_DIRS.
88# Example: "/home/media/media.lawrence.com/static/"
89STATIC_ROOT = ''
90
91# URL prefix for static files.
92# Example: "http://media.lawrence.com/static/"
93STATIC_URL = '/static/'
94
95# Additional locations of static files
96STATICFILES_DIRS = (
66ae88f4 97 os.path.join(ROOT_DIR, 'static'),
33234b2f
RB
98 # Put strings here, like "/home/html/static" or "C:/www/django/static".
99 # Always use forward slashes, even on Windows.
100 # Don't forget to use absolute paths, not relative paths.
101)
102
103# List of finder classes that know how to find static files in
104# various locations.
105STATICFILES_FINDERS = (
106 'django.contrib.staticfiles.finders.FileSystemFinder',
107 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
108# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
109)
110
111# Make this unique, and don't share it with anybody.
97a0ca06 112SECRET_KEY = 'FOR DEV ONLY!!'
33234b2f
RB
113
114# List of callables that know how to import templates from various sources.
115TEMPLATE_LOADERS = (
116 'django.template.loaders.filesystem.Loader',
117 'django.template.loaders.app_directories.Loader',
118# 'django.template.loaders.eggs.Loader',
119)
120
121MIDDLEWARE_CLASSES = (
122 'django.middleware.common.CommonMiddleware',
123 'django.contrib.sessions.middleware.SessionMiddleware',
124 'django.middleware.csrf.CsrfViewMiddleware',
125 'django.contrib.auth.middleware.AuthenticationMiddleware',
97a0ca06 126 'xnet.accounts.middleware.XnetAccountMiddleware',
33234b2f
RB
127 'django.contrib.messages.middleware.MessageMiddleware',
128 # Uncomment the next line for simple clickjacking protection:
129 # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
130)
131
132ROOT_URLCONF = 'xnet.urls'
133
134# Python dotted path to the WSGI application used by Django's runserver.
135WSGI_APPLICATION = 'xnet.wsgi.application'
136
137TEMPLATE_DIRS = (
ccb456d7 138 os.path.join(ROOT_DIR, 'templates'),
33234b2f
RB
139 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
140 # Always use forward slashes, even on Windows.
141 # Don't forget to use absolute paths, not relative paths.
142)
143
144INSTALLED_APPS = (
145 'django.contrib.auth',
146 'django.contrib.contenttypes',
147 'django.contrib.sessions',
148 'django.contrib.sites',
149 'django.contrib.messages',
150 'django.contrib.staticfiles',
151 'django.contrib.admin',
152
153 'django_authgroupex',
93adc7d4 154 'crispy_forms',
33234b2f 155 'xnet.site',
53722fb0 156 'xnet.accounts',
2f062660 157 'xnet.news',
563bc08c 158 'xnet.events',
33234b2f
RB
159 'xnet.example',
160)
161
162# A sample logging configuration. The only tangible logging
163# performed by this configuration is to send an email to
164# the site admins on every HTTP 500 error when DEBUG=False.
165# See http://docs.djangoproject.com/en/dev/topics/logging for
166# more details on how to customize your logging configuration.
167LOGGING = {
168 'version': 1,
169 'disable_existing_loggers': False,
170 'filters': {
171 'require_debug_false': {
172 '()': 'django.utils.log.RequireDebugFalse'
173 }
174 },
175 'handlers': {
176 'mail_admins': {
177 'level': 'ERROR',
178 'filters': ['require_debug_false'],
179 'class': 'django.utils.log.AdminEmailHandler'
180 }
181 },
182 'loggers': {
183 'django.request': {
184 'handlers': ['mail_admins'],
185 'level': 'ERROR',
186 'propagate': True,
187 },
188 }
189}
93adc7d4
CW
190
191CRISPY_TEMPLATE_PACK = 'bootstrap'