accounts: Add context_processor and middleware.
[xnet] / xnet / settings.py
1 # Django settings for xnet project.
2
3 DEBUG = True
4 TEMPLATE_DEBUG = DEBUG
5
6 import os.path
7 ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
8
9 def 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
14 ADMINS = (
15 # ('Your Name', 'your_email@example.com'),
16 )
17
18 MANAGERS = ADMINS
19
20 DATABASES = {
21 'default': {
22 'ENGINE': 'django.db.backends.sqlite3',
23 'NAME': os.path.join(ROOT_DIR, 'db.sqlite'),
24 }
25 }
26
27 AUTHENTICATION_BACKENDS = (
28 'django_authgroupex.auth.AuthGroupeXBackend',
29 )
30 AUTHGROUPEX_KEY = read_pass('authgroupex.key')
31 AUTHGROUPEX_FIELDS = ('username', 'firstname', 'lastname', 'perms')
32 AUTHGROUPEX_SUPERADMIN_PERMS = ('admin',)
33 AUTHGROUPEX_USER_MODEL = 'accounts.Account'
34 LOGIN_URL = '/xorgauth/'
35 LOGIN_REDIRECT_URL = '/'
36
37 AUTH_USER_MODEL = 'accounts.Account'
38
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.
43 TIME_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
47 LANGUAGE_CODE = 'en-us'
48 OCALE_PATHS = (
49 os.path.join(ROOT_DIR, 'locale'),
50 )
51
52 TEMPLATE_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 )
62
63 SITE_ID = 1
64
65 # If you set this to False, Django will make some optimizations so as not
66 # to load the internationalization machinery.
67 USE_I18N = True
68
69 # If you set this to False, Django will not format dates, numbers and
70 # calendars according to the current locale.
71 USE_L10N = True
72
73 # If you set this to False, Django will not use timezone-aware datetimes.
74 USE_TZ = True
75
76 # Absolute filesystem path to the directory that will hold user-uploaded files.
77 # Example: "/home/media/media.lawrence.com/media/"
78 MEDIA_ROOT = os.path.join(ROOT_DIR, 'media')
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/"
83 MEDIA_URL = '/media/'
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/"
89 STATIC_ROOT = ''
90
91 # URL prefix for static files.
92 # Example: "http://media.lawrence.com/static/"
93 STATIC_URL = '/static/'
94
95 # Additional locations of static files
96 STATICFILES_DIRS = (
97 os.path.join(ROOT_DIR, 'static'),
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.
105 STATICFILES_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.
112 SECRET_KEY = 'FOR DEV ONLY!!'
113
114 # List of callables that know how to import templates from various sources.
115 TEMPLATE_LOADERS = (
116 'django.template.loaders.filesystem.Loader',
117 'django.template.loaders.app_directories.Loader',
118 # 'django.template.loaders.eggs.Loader',
119 )
120
121 MIDDLEWARE_CLASSES = (
122 'django.middleware.common.CommonMiddleware',
123 'django.contrib.sessions.middleware.SessionMiddleware',
124 'django.middleware.csrf.CsrfViewMiddleware',
125 'django.contrib.auth.middleware.AuthenticationMiddleware',
126 'xnet.accounts.middleware.XnetAccountMiddleware',
127 'django.contrib.messages.middleware.MessageMiddleware',
128 # Uncomment the next line for simple clickjacking protection:
129 # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
130 )
131
132 ROOT_URLCONF = 'xnet.urls'
133
134 # Python dotted path to the WSGI application used by Django's runserver.
135 WSGI_APPLICATION = 'xnet.wsgi.application'
136
137 TEMPLATE_DIRS = (
138 os.path.join(ROOT_DIR, 'templates'),
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
144 INSTALLED_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',
154 'crispy_forms',
155 'xnet.site',
156 'xnet.accounts',
157 'xnet.news',
158 'xnet.events',
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.
167 LOGGING = {
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 }
190
191 CRISPY_TEMPLATE_PACK = 'bootstrap'