Add logout page (view, template, link)
[xnet] / xnet / settings / base.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(os.path.dirname(__file__)))
8
9 def read_pass(name):
10 fname = os.path.join(ROOT_DIR, 'private', name)
11 try:
12 with open(fname, 'r') as f:
13 return f.readline().strip()
14 except (OSError, IOError) as e:
15 print("Unable to read %s: %s" % (fname, e))
16 return ''
17
18 ADMINS = (
19 # ('Your Name', 'your_email@example.com'),
20 )
21
22 MANAGERS = ADMINS
23
24 CONTACT_EMAIL = 'contact@polytechnique.org'
25
26 AUTHENTICATION_BACKENDS = (
27 'django_authgroupex.auth.AuthGroupeXBackend',
28 )
29 AUTHGROUPEX_KEY = read_pass('authgroupex.key')
30 AUTHGROUPEX_FIELDS = ('username', 'firstname', 'lastname', 'perms')
31 AUTHGROUPEX_SUPERADMIN_PERMS = ('admin',)
32 AUTHGROUPEX_USER_MODEL = 'accounts.Account'
33 LOGIN_URL = '/xorgauth/'
34 LOGIN_REDIRECT_URL = '/'
35
36 AUTH_USER_MODEL = 'accounts.Account'
37
38 # Local time zone for this installation. Choices can be found here:
39 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
40 # although not all choices may be available on all operating systems.
41 # In a Windows environment this must be set to your system time zone.
42 TIME_ZONE = 'Europe/Paris'
43
44 # Language code for this installation. All choices can be found here:
45 # http://www.i18nguy.com/unicode/language-identifiers.html
46 LANGUAGE_CODE = 'en-us'
47 OCALE_PATHS = (
48 os.path.join(ROOT_DIR, 'locale'),
49 )
50
51 TEMPLATE_CONTEXT_PROCESSORS = (
52 'django.contrib.auth.context_processors.auth',
53 'django.core.context_processors.debug',
54 'django.core.context_processors.i18n',
55 'django.core.context_processors.media',
56 'django.core.context_processors.static',
57 'django.core.context_processors.tz',
58 'django.contrib.messages.context_processors.messages',
59 'xnet.site.context_processors.public_settings',
60 'xnet.groups.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.groups.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 # site app defines registration/ templates which overwrite other apps
146 'xnet.site',
147
148 'django.contrib.auth',
149 'django.contrib.contenttypes',
150 'django.contrib.sessions',
151 'django.contrib.sites',
152 'django.contrib.messages',
153 'django.contrib.staticfiles',
154 'django.contrib.admin',
155
156 'django_authgroupex',
157 'crispy_forms',
158
159 'xnet.accounts',
160 'xnet.groups',
161 'xnet.news',
162 'xnet.events',
163 'xnet.profiles',
164 )
165
166 # A sample logging configuration. The only tangible logging
167 # performed by this configuration is to send an email to
168 # the site admins on every HTTP 500 error when DEBUG=False.
169 # See http://docs.djangoproject.com/en/dev/topics/logging for
170 # more details on how to customize your logging configuration.
171 LOGGING = {
172 'version': 1,
173 'disable_existing_loggers': False,
174 'filters': {
175 'require_debug_false': {
176 '()': 'django.utils.log.RequireDebugFalse'
177 }
178 },
179 'handlers': {
180 'mail_admins': {
181 'level': 'ERROR',
182 'filters': ['require_debug_false'],
183 'class': 'django.utils.log.AdminEmailHandler'
184 }
185 },
186 'loggers': {
187 'django.request': {
188 'handlers': ['mail_admins'],
189 'level': 'ERROR',
190 'propagate': True,
191 },
192 }
193 }
194
195 CRISPY_TEMPLATE_PACK = 'bootstrap'