This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
forked from ofri/Open-Knesset
/
settings.py
357 lines (291 loc) · 10.4 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# encoding: utf-8
# Django settings for knesset project.
import os
import logging
from datetime import timedelta
# dummy gettext, to get django-admin makemessages to find i18n texts in this file
import sys
gettext = lambda x: x
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'NAME': 'dev.db',
'ENGINE': 'django.db.backends.sqlite3',
},
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Asia/Jerusalem'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'he'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.path.pardir
))
DATA_ROOT = os.path.join(PROJECT_ROOT, 'data', '')
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media', '')
# Absolute path to location of collected static files
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static_root', '')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1_ovxxkf(c*z_dwv!(-=dezf#%l(po5%#zzi*su-$d*_j*1sr+'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'sslify.middleware.SSLifyMiddleware',
'django.middleware.gzip.GZipMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', # keep after session
'django.middleware.csrf.CsrfViewMiddleware',
'pagination.middleware.PaginationMiddleware',
'waffle.middleware.WaffleMiddleware',
# make sure to keep the DebugToolbarMiddleware last
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
AUTHENTICATION_BACKENDS = (
'social.backends.twitter.TwitterOAuth',
'social.backends.facebook.FacebookOAuth2',
'social.backends.google.GoogleOAuth2',
'social.backends.google.GoogleOAuth',
'social.backends.github.GithubOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_CREATE_USERS = True
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
SOCIAL_AUTH_ASSOCIATE_BY_MAIL = True
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['username', 'first_name', 'email']
# These keys will work for 127.0.0.1:8000
# and are overriden in the production server.
SOCIAL_AUTH_TWITTER_KEY = 'KFZkQgImAyECXDS6tQTvOw'
SOCIAL_AUTH_TWITTER_SECRET = 's6ir2FMqw4fqXQbX4QCE6Ka1lRjycXxJuG6k8tYc'
ROOT_URLCONF = 'knesset.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_ROOT, 'templates'),
)
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'), # Finding current static files
)
LOCALE_PATHS = (
os.path.join(PROJECT_ROOT, 'locale'),
)
INSTALLED_APPS = (
'django.contrib.auth', # django apps
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.comments',
'django.contrib.sitemaps',
'django.contrib.flatpages',
'django.contrib.messages',
'django.contrib.staticfiles',
'tastypie_swagger',
'debug_toolbar',
'tagging',
'south',
'planet',
'pagination',
'django_extensions',
'actstream',
'avatar',
'annotatetext',
'mailer',
'backlinks',
'backlinks.pingback',
'backlinks.trackback',
'django_nose',
'gunicorn',
'djangoratings',
'voting',
'social.apps.django_app.default',
'devserver',
'crispy_forms',
'storages',
'corsheaders',
'sslserver',
'waffle',
'import_export',
# 'knesset',
'auxiliary', # knesset apps
'mks',
'mmm',
'laws',
'committees',
'simple',
'tagvotes',
'accounts',
'links',
'user',
'agendas',
'notify',
'persons',
'events',
'video',
'okhelptexts',
'tastypie',
'polyorg',
'plenum',
'tinymce',
'suggestions',
'okscraper_django',
'lobbyists',
'kikar',
'ok_tag',
'django_slack'
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"knesset.context.processor",
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
)
INTERNAL_IPS = ()
# Add the following line to your local_settings.py files to enable django-debug-toolar:
# INTERNAL_IPS = ('127.0.0.1',)
LOCAL_DEV = True
LOGIN_URL = '/users/login/'
SITE_NAME = 'Open-Knesset'
MAX_TAG_LENGTH = 128
AUTH_PROFILE_MODULE = 'user.UserProfile'
LOGIN_REDIRECT_URL = '/'
USER_AGENT = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
LOG_FILENAME = os.path.join(PROJECT_ROOT, 'open-knesset.log')
file_logger = logging.getLogger("open-knesset")
file_logger.setLevel(logging.DEBUG) # override this in prod server to logging.ERROR
h = logging.FileHandler(LOG_FILENAME)
h.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s\t%(name)s:%(lineno)d\t%(levelname)s\t%(message)s")
h.setFormatter(formatter)
file_logger.addHandler(h)
# Console loggers, Best practice always log to stdout and stderr and let third party environment to deal with logging
# See 12 factor app http://12factor.net/logs
# Todo refactor this to support stderr and out and more dynamic config supporting sentry etc
console_logger = logging.getLogger('') # root logger
console_logger.setLevel(logging.WARNING)
stdout_handler = logging.StreamHandler(stream=sys.stdout)
stdout_handler.setFormatter(formatter)
console_logger.addHandler(stdout_handler)
GOOGLE_CUSTOM_SEARCH = "007833092092208924626:1itz_l8x4a4"
GOOGLE_MAPS_API_KEYS = {'dev': 'ABQIAAAAWCfW8hHVwzZc12qTG0qLEhQCULP4XOMyhPd8d_NrQQEO8sT8XBQdS2fOURLgU1OkrUWJE1ji1lJ-3w',
'prod': 'ABQIAAAAWCfW8hHVwzZc12qTG0qLEhR8lgcBs8YFes75W3FA_wpyzLVCpRTF-eaJoRuCHAJ2qzVu-Arahwp8QA'}
GOOGLE_MAPS_API_KEY = GOOGLE_MAPS_API_KEYS['dev'] # override this in prod server
# you need to generate a token and put it in local_settings.py
# to generate a token run: bin/django update_videos --get-youtube-token
YOUTUBE_AUTHSUB_TOKEN = ''
# you need to get a developer key and put it in local_settings.py
# to get a developer key goto: http://code.google.com/apis/youtube/dashboard
YOUTUBE_DEVELOPER_KEY = ''
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
LONG_CACHE_TIME = 18000 # 5 hours
ANNOTATETEXT_FLAGS = (
gettext('Statement'),
gettext('Funny :-)'),
gettext('False fact'),
gettext('Source?'),
gettext('Found source'),
gettext('Cross reference'),
gettext('Important'),
gettext('Formatting/Error!'),
gettext('Comment'),
)
AUTO_GENERATE_AVATAR_SIZES = (75, 48)
AVATAR_GRAVATAR_BASE_URL = 'https://www.gravatar.com/avatar/'
NOSE_ARGS = ['--with-xunit']
SERIALIZATION_MODULES = {
'oknesset': 'auxiliary.serializers'
}
API_LIMIT_PER_PAGE = 1000
SOUTH_TESTS_MIGRATE = False
SOUTH_MIGRATION_MODULES = {
'waffle': 'waffle.south_migrations',
}
TINYMCE_DEFAULT_CONFIG = {
'mode': "textareas",
'theme': "advanced",
'plugins': "paste",
'theme_advanced_buttons1': ("bold,italic,underline,|,undo,redo,|,"
"link,unlink,|,bullist,numlist,|"
",cut,copy,paste,pastetext,|,cleanup"),
'theme_advanced_buttons2': "",
'theme_advanced_buttons3': "",
'theme_advanced_toolbar_align': "center",
}
DEVSERVER_DEFAULT_ADDR = '127.0.0.1'
DEVSERVER_DEFAULT_PORT = 8000
# This is for socialauth is it can't serilaize correctly datetime.datetime. A
# JSON serialzer is preferred and changed to be the default in 1.6, but we'll
# have to keep it for now. For more info, see:
# https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
#
# TODO: Look into switching to django-allauth instead and using the session
# serializer.
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
TASTYPIE_SWAGGER_API_MODULE = 'apis.resources.v2_api'
# By default auto-SSL disabled, on production machines local_settings overrides
# to False
SSLIFY_DISABLE = True
# in production you might want to limit it in local_settings
CORS_ORIGIN_ALLOW_ALL = True
JWT_EXPIRATION_DELTA = timedelta(hours=48)
JWT_ALGORITHM = 'HS256'
LOGIN_REDIRECT_TARGETS = {
'opensubs': {
'parent_location_href': 'http://localhost:9000/',
'redirect_to_url': 'http://localhost:9000/#/login/',
'fb_secret': ''
}
}
KIKAR_BASE_URL = 'http://www.kikar.org'
# if you add a local_settings.py file, it will override settings here
# but please, don't commit it to git.
DEBUG_TOOLBAR_PATCH_SETTINGS = False
TEST_RUNNER = 'knesset.common_test_runner.KnessetTestRunner'
DEVSERVER_MODULES = (
# 'devserver.modules.sql.SQLRealTimeModule',
'devserver.modules.sql.SQLSummaryModule',
'devserver.modules.profile.ProfileSummaryModule',
# 'devserver.modules.profile.MemoryUseModule'
)
try:
from local_settings import *
except ImportError:
pass