root / djnro / settings.py @ 7aaa7741
History | View | Annotate | Download (8.9 kB)
1 |
# -*- coding: utf-8 -*- vim:fileencoding=utf-8:
|
---|---|
2 |
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
|
3 |
# Django settings for djnro project.
|
4 |
|
5 |
# Copyright © 2011-2014 Greek Research and Technology Network (GRNET S.A.)
|
6 |
# Copyright © 2011-2014 Leonidas Poulopoulos (@leopoul)
|
7 |
# Copyright © 2011-2014 Zenon Mousmoulas
|
8 |
# Copyright © 2014 Stavros Kroustouris
|
9 |
|
10 |
# Developed by Leonidas Poulopoulos (leopoul-at-noc-dot-grnet-dot-gr),
|
11 |
# Zenon Mousmoulas (zmousm-at-noc-dot-grnet-dot-gr) and Stavros Kroustouris
|
12 |
# (staurosk-at-noc-dot-grnet-dot-gr), GRNET NOC
|
13 |
#
|
14 |
|
15 |
# Permission to use, copy, modify, and/or distribute this software for any
|
16 |
# purpose with or without fee is hereby granted, provided that the above
|
17 |
# copyright notice and this permission notice appear in all copies.
|
18 |
#
|
19 |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD
|
20 |
# TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
21 |
# FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
22 |
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
23 |
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
24 |
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
25 |
# SOFTWARE.
|
26 |
|
27 |
from django.utils.translation import ugettext as _ |
28 |
import os |
29 |
|
30 |
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
31 |
PROJECT_DIR = os.path.join(BASE_DIR, 'djnro')
|
32 |
|
33 |
LOCALE_PATHS = ( |
34 |
os.path.join(BASE_DIR, 'locale'),
|
35 |
) |
36 |
|
37 |
LANGUAGES = ( |
38 |
('el', _('Greek')), |
39 |
('en', _('English')), |
40 |
) |
41 |
|
42 |
# Language code for this installation. All choices can be found here:
|
43 |
# http://www.i18nguy.com/unicode/language-identifiers.html
|
44 |
LANGUAGE_CODE = 'en'
|
45 |
|
46 |
SITE_ID = 1
|
47 |
|
48 |
# If you set this to False, Django will make some optimizations so as not
|
49 |
# to load the internationalization machinery.
|
50 |
USE_I18N = True
|
51 |
|
52 |
# If you set this to False, Django will not format dates, numbers and
|
53 |
# calendars according to the current locale.
|
54 |
USE_L10N = True
|
55 |
|
56 |
# If you set this to False, Django will not use timezone-aware datetimes.
|
57 |
USE_TZ = True
|
58 |
|
59 |
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
60 |
# Example: "/home/media/media.lawrence.com/media/"
|
61 |
MEDIA_ROOT = ''
|
62 |
|
63 |
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
64 |
# trailing slash.
|
65 |
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
66 |
MEDIA_URL = ''
|
67 |
|
68 |
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
69 |
# trailing slash.
|
70 |
# Examples: "http://foo.com/media/", "/media/".
|
71 |
ADMIN_MEDIA_PREFIX = '/media/'
|
72 |
|
73 |
# STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
74 |
STATICFILES_DIRS = [ |
75 |
os.path.join(BASE_DIR, 'static'),
|
76 |
] |
77 |
|
78 |
|
79 |
# List of finder classes that know how to find static files in
|
80 |
# various locations.
|
81 |
STATICFILES_FINDERS = ( |
82 |
'django.contrib.staticfiles.finders.FileSystemFinder',
|
83 |
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
84 |
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
85 |
) |
86 |
|
87 |
# List of callables that know how to import templates from various sources.
|
88 |
TEMPLATE_LOADERS = ( |
89 |
'django.template.loaders.filesystem.Loader',
|
90 |
'django.template.loaders.app_directories.Loader',
|
91 |
# 'django.template.loaders.eggs.Loader',
|
92 |
) |
93 |
|
94 |
TEMPLATE_CONTEXT_PROCESSORS = ( |
95 |
# Required so that RequestContext is passed into
|
96 |
# template
|
97 |
'django.contrib.auth.context_processors.auth',
|
98 |
'django.core.context_processors.debug',
|
99 |
'django.core.context_processors.i18n',
|
100 |
'django.core.context_processors.media',
|
101 |
'django.core.context_processors.request',
|
102 |
'edumanage.context_processors.country_code',
|
103 |
'edumanage.context_processors.cat_instances',
|
104 |
'social.apps.django_app.context_processors.backends',
|
105 |
'social.apps.django_app.context_processors.login_redirect',
|
106 |
) |
107 |
|
108 |
MIDDLEWARE_CLASSES = ( |
109 |
'django.middleware.cache.UpdateCacheMiddleware',
|
110 |
'django.middleware.gzip.GZipMiddleware',
|
111 |
'django.middleware.common.CommonMiddleware',
|
112 |
'django.contrib.sessions.middleware.SessionMiddleware',
|
113 |
'django.middleware.locale.LocaleMiddleware',
|
114 |
'django.middleware.csrf.CsrfViewMiddleware',
|
115 |
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
116 |
'django.contrib.messages.middleware.MessageMiddleware',
|
117 |
'django.middleware.cache.FetchFromCacheMiddleware',
|
118 |
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
|
119 |
# Uncomment the next line for simple clickjacking protection:
|
120 |
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
121 |
) |
122 |
|
123 |
AUTHENTICATION_BACKENDS = ( |
124 |
'djangobackends.shibauthBackend.shibauthBackend',
|
125 |
# 'django_auth_ldap.backend.LDAPBackend',
|
126 |
'social.backends.twitter.TwitterOAuth',
|
127 |
'social.backends.google.GoogleOpenIdConnect',
|
128 |
# 'social.backends.facebook.FacebookOAuth2',
|
129 |
|
130 |
'social.backends.google.GoogleOAuth2',
|
131 |
# 'social.backends.google.GoogleOAuth',
|
132 |
# 'social.backends.linkedin.LinkedinOAuth2',
|
133 |
# 'social.backends.yahoo.YahooOpenId',
|
134 |
# 'social.backends.open_id.OpenIdAuth',
|
135 |
|
136 |
'django.contrib.auth.backends.ModelBackend',
|
137 |
) |
138 |
|
139 |
ROOT_URLCONF = 'djnro.urls'
|
140 |
|
141 |
# Python dotted path to the WSGI application used by Django's runserver.
|
142 |
WSGI_APPLICATION = 'djnro.wsgi.application'
|
143 |
|
144 |
TEMPLATE_DIRS = ( |
145 |
os.path.join(PROJECT_DIR, 'templates/'),
|
146 |
os.path.join(BASE_DIR, 'templates/'),
|
147 |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
148 |
# Always use forward slashes, even on Windows.
|
149 |
# Don't forget to use absolute paths, not relative paths.
|
150 |
) |
151 |
|
152 |
INSTALLED_APPS = ( |
153 |
'longerusername',
|
154 |
'django.contrib.auth',
|
155 |
'django.contrib.contenttypes',
|
156 |
'django.contrib.sessions',
|
157 |
'django.contrib.sites',
|
158 |
'django.contrib.messages',
|
159 |
'django.contrib.staticfiles',
|
160 |
'django.contrib.flatpages',
|
161 |
'django.contrib.markup',
|
162 |
'django.contrib.admin',
|
163 |
'django.contrib.admindocs',
|
164 |
'django.contrib.staticfiles',
|
165 |
'social.apps.django_app.default',
|
166 |
'edumanage',
|
167 |
'accounts',
|
168 |
'south',
|
169 |
'registration',
|
170 |
'tinymce',
|
171 |
'utils',
|
172 |
'oauthlib',
|
173 |
) |
174 |
|
175 |
# A sample logging configuration. The only tangible logging
|
176 |
# performed by this configuration is to send an email to
|
177 |
# the site admins on every HTTP 500 error when DEBUG=False.
|
178 |
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
179 |
# more details on how to customize your logging configuration.
|
180 |
# LOGGING = {
|
181 |
# 'version': 1,
|
182 |
# 'disable_existing_loggers': False,
|
183 |
# 'filters': {
|
184 |
# 'require_debug_false': {
|
185 |
# '()': 'django.utils.log.RequireDebugFalse'
|
186 |
# }
|
187 |
# },
|
188 |
# 'handlers': {
|
189 |
# 'mail_admins': {
|
190 |
# 'level': 'ERROR',
|
191 |
# 'filters': ['require_debug_false'],
|
192 |
# 'class': 'django.utils.log.AdminEmailHandler'
|
193 |
# }
|
194 |
# },
|
195 |
# 'loggers': {
|
196 |
# 'django.request': {
|
197 |
# 'handlers': ['mail_admins'],
|
198 |
# 'level': 'ERROR',
|
199 |
# 'propagate': True,
|
200 |
# },
|
201 |
# }
|
202 |
# }
|
203 |
|
204 |
|
205 |
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
|
206 |
|
207 |
LOGIN_URL = '/manage/login/'
|
208 |
|
209 |
KML_FILE = os.path.join(PROJECT_DIR, 'all.kml')
|
210 |
INST_XML_FILE = os.path.join(PROJECT_DIR, 'institution.xml')
|
211 |
|
212 |
EDUROAM_KML_URL = 'http://monitor.eduroam.org/kml/all.kml'
|
213 |
|
214 |
|
215 |
|
216 |
TINYMCE_JS_URL = '/static/js/tinymce/tiny_mce.js'
|
217 |
|
218 |
TINYMCE_DEFAULT_CONFIG = { |
219 |
'extended_valid_elements' : 'iframe[src|width|height|name|align]', |
220 |
'plugins': "table,spellchecker,paste,searchreplace", |
221 |
'theme': "advanced", |
222 |
} |
223 |
|
224 |
|
225 |
#Name_i18n, URL_i18n, language choice field
|
226 |
# If it's the same with LANGUAGES, simply do URL_NAME_LANGS = LANGUAGES
|
227 |
URL_NAME_LANGS = ( |
228 |
('en', 'English' ), |
229 |
('el', 'Ελληνικά'), |
230 |
) |
231 |
|
232 |
SOCIAL_AUTH_FORCE_POST_DISCONNECT = True
|
233 |
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
|
234 |
SOCIAL_AUTH_CREATE_USERS = True
|
235 |
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
|
236 |
SOCIAL_AUTH_SANITIZE_REDIRECTS = False
|
237 |
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
238 |
|
239 |
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/manage/'
|
240 |
LOGIN_REDIRECT_URL = '/manage/'
|
241 |
SOCIAL_AUTH_INACTIVE_USER_URL = '/manage/'
|
242 |
SOCIAL_AUTH_FORCE_POST_DISCONNECT = True
|
243 |
|
244 |
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
|
245 |
|
246 |
|
247 |
LINKEDIN_EXTRA_FIELD_SELECTORS = ['email-address', 'headline', 'industry'] |
248 |
LINKEDIN_SCOPE = ['r_basicprofile', 'r_emailaddress'] |
249 |
|
250 |
LINKEDIN_EXTRA_DATA = [('id', 'id'), |
251 |
('first-name', 'first_name'), |
252 |
('last-name', 'last_name'), |
253 |
('email-address', 'email_address'), |
254 |
('headline', 'headline'), |
255 |
('industry', 'industry')] |
256 |
|
257 |
|
258 |
CAT_INSTANCES = () |
259 |
|
260 |
import _version |
261 |
SW_VERSION = _version.VERSION |
262 |
|
263 |
def _dictmerge(a, b): |
264 |
""" deep merge two dictionaries """
|
265 |
ret = dict(a.items() + b.items())
|
266 |
for key in set(a.keys()) & set(b.keys()): |
267 |
if isinstance(a[key], dict) and isinstance(b[key], dict): |
268 |
ret[key] = _dictmerge(a[key], b[key]) |
269 |
return ret
|
270 |
|
271 |
from local_settings import * # noqa |
272 |
for var, val in [i for i in locals().items() if i[0].startswith('EXTRA_')]: |
273 |
name = var[len('EXTRA_'):] |
274 |
try:
|
275 |
locals()[name] += val # append list |
276 |
except TypeError: |
277 |
locals()[name] = _dictmerge(locals()[name], val) # merge dict |