Statistics
| Branch: | Tag: | Revision:

root / djnro / settings.py @ d3ea44a4

History | View | Annotate | Download (9.6 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
here = lambda x: os.path.join(os.path.abspath(os.path.dirname(__file__)), x)
31
djnro_path = os.path.join(os.path.abspath(os.path.dirname(__file__)))
32
project_path = os.path.abspath(os.path.dirname(__name__))
33

    
34
# Local time zone for this installation. Choices can be found here:
35
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
36
# although not all choices may be available on all operating systems.
37
# In a Windows environment this must be set to your system time zone.
38
TIME_ZONE = 'Europe/Athens'
39

    
40
LOCALE_PATHS = (
41
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'locale'),
42
)
43

    
44
LANGUAGES = (
45
    ('el', _('Greek')),
46
    ('en', _('English')),
47
)
48

    
49
# Language code for this installation. All choices can be found here:
50
# http://www.i18nguy.com/unicode/language-identifiers.html
51
LANGUAGE_CODE = 'en'
52

    
53
SITE_ID = 1
54

    
55
# If you set this to False, Django will make some optimizations so as not
56
# to load the internationalization machinery.
57
USE_I18N = True
58

    
59
# If you set this to False, Django will not format dates, numbers and
60
# calendars according to the current locale.
61
USE_L10N = True
62

    
63
# If you set this to False, Django will not use timezone-aware datetimes.
64
USE_TZ = True
65

    
66
# Absolute filesystem path to the directory that will hold user-uploaded files.
67
# Example: "/home/media/media.lawrence.com/media/"
68
MEDIA_ROOT = ''
69

    
70
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
71
# trailing slash.
72
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
73
MEDIA_URL = ''
74

    
75
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
76
# trailing slash.
77
# Examples: "http://foo.com/media/", "/media/".
78
ADMIN_MEDIA_PREFIX = '/media/'
79

    
80
# STATIC_ROOT = os.path.join(project_path, 'static')
81
STATICFILES_DIRS = [
82
    os.path.join(project_path, 'static'),
83
]
84

    
85

    
86
# List of finder classes that know how to find static files in
87
# various locations.
88
STATICFILES_FINDERS = (
89
    'django.contrib.staticfiles.finders.FileSystemFinder',
90
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
91
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
92
)
93

    
94
# List of callables that know how to import templates from various sources.
95
TEMPLATE_LOADERS = (
96
    'django.template.loaders.filesystem.Loader',
97
    'django.template.loaders.app_directories.Loader',
98
#     'django.template.loaders.eggs.Loader',
99
)
100

    
101
TEMPLATE_CONTEXT_PROCESSORS = (
102
    # Required so that RequestContext is passed into
103
    # template
104
    'django.contrib.auth.context_processors.auth',
105
    'django.core.context_processors.debug',
106
    'django.core.context_processors.i18n',
107
    'django.core.context_processors.media',
108
    'django.core.context_processors.request',
109
    'edumanage.context_processors.country_code',
110
    'edumanage.context_processors.cat_instances',
111
    'social_auth.context_processors.social_auth_by_type_backends',
112
)
113

    
114
MIDDLEWARE_CLASSES = (
115
    'django.middleware.cache.UpdateCacheMiddleware',
116
    'django.middleware.gzip.GZipMiddleware',
117
    'django.middleware.common.CommonMiddleware',
118
    'django.contrib.sessions.middleware.SessionMiddleware',
119
    'django.middleware.locale.LocaleMiddleware',
120
    'django.middleware.csrf.CsrfViewMiddleware',
121
    'django.contrib.auth.middleware.AuthenticationMiddleware',
122
    'django.contrib.messages.middleware.MessageMiddleware',
123
    'django.middleware.cache.FetchFromCacheMiddleware',
124
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
125
    'edumanage.middleware.WrongBackendExceptionMiddleware',
126
    # Uncomment the next line for simple clickjacking protection:
127
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
128
)
129

    
130
AUTHENTICATION_BACKENDS = (
131
    'djangobackends.shibauthBackend.shibauthBackend',
132
    # 'django_auth_ldap.backend.LDAPBackend',
133
    'social_auth.backends.twitter.TwitterBackend',
134
    'social_auth.backends.facebook.FacebookBackend',
135
    'social_auth.backends.google.GoogleBackend',
136
    'social_auth.backends.contrib.linkedin.LinkedinBackend',
137
    'social_auth.backends.contrib.yahoo.YahooOAuthBackend',
138
    'social_auth.backends.yahoo.YahooBackend',
139
    'social_auth.backends.OpenIDBackend',
140
    'django.contrib.auth.backends.ModelBackend',
141
)
142

    
143
ROOT_URLCONF = 'djnro.urls'
144

    
145
# Python dotted path to the WSGI application used by Django's runserver.
146
WSGI_APPLICATION = 'djnro.wsgi.application'
147

    
148
TEMPLATE_DIRS = (
149
    os.path.join(djnro_path, 'templates/'),
150
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
151
    # Always use forward slashes, even on Windows.
152
    # Don't forget to use absolute paths, not relative paths.
153
)
154

    
155
INSTALLED_APPS = (
156
    'longerusername',
157
    'django.contrib.auth',
158
    'django.contrib.contenttypes',
159
    'django.contrib.sessions',
160
    'django.contrib.sites',
161
    'django.contrib.messages',
162
    'django.contrib.staticfiles',
163
    'django.contrib.flatpages',
164
    'django.contrib.markup',
165
    'django.contrib.admin',
166
    'django.contrib.admindocs',
167
    'django.contrib.staticfiles',
168
    'edumanage',
169
    'accounts',
170
    'south',
171
    'registration',
172
    'tinymce',
173
    'social_auth',
174
    'utils',
175
)
176

    
177
# A sample logging configuration. The only tangible logging
178
# performed by this configuration is to send an email to
179
# the site admins on every HTTP 500 error when DEBUG=False.
180
# See http://docs.djangoproject.com/en/dev/topics/logging for
181
# more details on how to customize your logging configuration.
182
# LOGGING = {
183
#     'version': 1,
184
#     'disable_existing_loggers': False,
185
#     'filters': {
186
#         'require_debug_false': {
187
#             '()': 'django.utils.log.RequireDebugFalse'
188
#         }
189
#     },
190
#     'handlers': {
191
#         'mail_admins': {
192
#             'level': 'ERROR',
193
#             'filters': ['require_debug_false'],
194
#             'class': 'django.utils.log.AdminEmailHandler'
195
#         }
196
#     },
197
#     'loggers': {
198
#         'django.request': {
199
#             'handlers': ['mail_admins'],
200
#             'level': 'ERROR',
201
#             'propagate': True,
202
#         },
203
#     }
204
# }
205

    
206

    
207
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
208

    
209
LOGIN_URL = '/manage/login/'
210

    
211
KML_FILE = here('all.kml')
212
INST_XML_FILE = here('institution.xml')
213

    
214
EDUROAM_KML_URL = 'http://monitor.eduroam.org/kml/all.kml'
215

    
216

    
217

    
218
TINYMCE_JS_URL = '/static/js/tinymce/tiny_mce.js'
219

    
220
TINYMCE_DEFAULT_CONFIG = {
221
    'extended_valid_elements' :  'iframe[src|width|height|name|align]',
222
    'plugins': "table,spellchecker,paste,searchreplace",
223
    'theme': "advanced",
224
}
225

    
226

    
227
#Name_i18n, URL_i18n, language choice field
228
# If it's the same with LANGUAGES, simply do URL_NAME_LANGS = LANGUAGES
229
URL_NAME_LANGS = (
230
    ('en', 'English' ),
231
    ('el', 'Ελληνικά'),
232
)
233

    
234
SOCIAL_AUTH_FORCE_POST_DISCONNECT = True
235
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
236
SOCIAL_AUTH_CREATE_USERS = True
237
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
238
SOCIAL_AUTH_SANITIZE_REDIRECTS = False
239
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
240

    
241
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/manage/'
242
LOGIN_REDIRECT_URL = '/manage/'
243
SOCIAL_AUTH_INACTIVE_USER_URL = '/manage/'
244
SOCIAL_AUTH_FORCE_POST_DISCONNECT = True
245

    
246
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
247

    
248

    
249
LINKEDIN_EXTRA_FIELD_SELECTORS = ['email-address', 'headline', 'industry']
250
LINKEDIN_SCOPE = ['r_basicprofile', 'r_emailaddress']
251

    
252
LINKEDIN_EXTRA_DATA = [('id', 'id'),
253
                       ('first-name', 'first_name'),
254
                       ('last-name', 'last_name'),
255
                       ('email-address', 'email_address'),
256
                       ('headline', 'headline'),
257
                       ('industry', 'industry')]
258

    
259

    
260
SOCIAL_AUTH_PIPELINE = (
261
    'social_auth.backends.pipeline.social.social_auth_user',
262
    'social_auth.backends.pipeline.user.get_username',
263
    'social_auth.backends.pipeline.user.create_user',
264
    'social_auth.backends.pipeline.social.associate_user',
265
    'social_auth.backends.pipeline.social.load_extra_data',
266
    'social_auth.backends.pipeline.user.update_user_details',
267
)
268

    
269
CAT_INSTANCES = ()
270

    
271
import _version
272
SW_VERSION = _version.VERSION
273

    
274
def _dictmerge(a, b):
275
    """ deep merge two dictionaries """
276
    ret = dict(a.items() + b.items())
277
    for key in set(a.keys()) & set(b.keys()):
278
        if isinstance(a[key], dict) and isinstance(b[key], dict):
279
            ret[key] = _dictmerge(a[key], b[key])
280
    return ret
281

    
282
from local_settings import *  # noqa
283
for var, val in [i for i in locals().items() if i[0].startswith('EXTRA_')]:
284
    name = var[len('EXTRA_'):]
285
    try:
286
        locals()[name] += val  # append list
287
    except TypeError:
288
        locals()[name] = _dictmerge(locals()[name], val)  # merge dict