70512cb57f0ed7d1ed2ee40c5a94f5b80f20c80f
[redakcja.git] / src / redakcja / settings / __init__.py
1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 import os.path
5 import sentry_sdk
6 from sentry_sdk.integrations.django import DjangoIntegration
7 from .defaults import *
8 from ..localsettings import *
9
10 DATA_UPLOAD_MAX_MEMORY_SIZE = 20000000
11
12 PROJECT_ROOT = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
13
14 STATICFILES_DIRS = [
15     PROJECT_ROOT + '/static/'
16 ]
17
18 TEMPLATES = [
19     {
20         'BACKEND': 'django.template.backends.django.DjangoTemplates',
21         'APP_DIRS': True,
22         'DIRS': [
23             PROJECT_ROOT + '/templates',
24         ],
25         'OPTIONS': {
26             'context_processors': [
27                 "django.contrib.auth.context_processors.auth",
28                 "django.template.context_processors.debug",
29                 "django.template.context_processors.i18n",
30                 "redakcja.context_processors.settings", # this is instead of media
31                 'django.template.context_processors.csrf',
32                 "django.template.context_processors.request",
33                 "django.contrib.messages.context_processors.messages",
34             ],
35         },
36     },
37 ]
38
39 MIDDLEWARE = [
40     'django.middleware.common.CommonMiddleware',
41     'django.middleware.csrf.CsrfViewMiddleware',
42     'django.contrib.sessions.middleware.SessionMiddleware',
43     'django.contrib.messages.middleware.MessageMiddleware',
44
45     'django.contrib.auth.middleware.AuthenticationMiddleware',
46     ]
47
48 if CAS_SERVER_URL:
49     MIDDLEWARE.append(
50         'django_cas_ng.middleware.CASMiddleware',
51     )
52
53 MIDDLEWARE += [
54     'django.contrib.admindocs.middleware.XViewMiddleware',
55     'fnp_django_pagination.middleware.PaginationMiddleware',
56 ]
57
58 if DEBUG:
59     MIDDLEWARE = [
60         'debug_toolbar.middleware.DebugToolbarMiddleware',
61     ] + MIDDLEWARE
62
63 if CAS_SERVER_URL:
64     AUTHENTICATION_BACKENDS = (
65         'django.contrib.auth.backends.ModelBackend',
66         'django_cas_ng.backends.CASBackend',
67     )
68
69 ROOT_URLCONF = 'redakcja.urls'
70
71 INSTALLED_APPS = (
72     'modeltranslation',
73
74     'django.contrib.auth',
75     'django.contrib.contenttypes',
76     'django.contrib.sessions',
77     'django.contrib.messages',
78     'django.contrib.staticfiles',
79     'django.contrib.sites',
80     'admin_numeric_filter',
81     'django.contrib.admin',
82     'django.contrib.admindocs',
83
84     'sorl.thumbnail',
85     'fnp_django_pagination',
86     'django_gravatar',
87     'fileupload',
88     'pipeline',
89     'fnpdjango',
90     'django_cas_ng',
91     'bootstrap4',
92     'rest_framework',
93     'django_filters',
94     'admin_ordering',
95
96     'redakcja.api',
97     'catalogue',
98     'depot',
99     'documents',
100     'cover',
101     'dvcs',
102     'wiki',
103     'wiki_img',
104     'toolbar',
105     'apiclient',
106     'email_mangler',
107     'wlxml.apps.WlxmlConfig',
108     'alerts',
109     'team',
110 )
111
112 if DEBUG:
113     INSTALLED_APPS += ('debug_toolbar',)
114
115 LOCALE_PATHS = [
116     PROJECT_ROOT + "/locale-contrib",
117 ]
118
119 LOGIN_REDIRECT_URL = '/documents/user'
120
121 MIN_COVER_SIZE = (915, 1270)
122
123 LEGIMI_SMALL_WORDS = 2000
124 LEGIMI_BIG_WORDS = 10000
125 LEGIMI_SMALL_PRICE = 7
126 LEGIMI_BIG_PRICE = 20
127
128 THUMBNAIL_PRESERVE_FORMAT = True
129
130 STATICFILES_FINDERS = (
131     'django.contrib.staticfiles.finders.FileSystemFinder',
132     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
133     'pipeline.finders.PipelineFinder',
134 )
135
136 STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
137
138 PIPELINE = {
139     'CSS_COMPRESSOR': None,
140     'JS_COMPRESSOR': None,
141     'COMPILERS': (
142         'libsasscompiler.LibSassCompiler',
143     ),
144
145     # CSS and JS files to compress
146     'STYLESHEETS': {
147         'detail': {
148             'source_filenames': (
149                 'css/html.scss',
150                 'css/master.css',
151                 'css/toolbar.css',
152                 'css/gallery.css',
153                 'css/history.css',
154                 'css/summary.css',
155                 'css/imgareaselect-default.css',
156                 'css/dialogs.css',
157
158                 'wiki/scss/splitter.scss',
159                 'wiki/scss/visual.scss'
160             ),
161             'output_filename': 'compressed/detail_styles.css',
162         },
163         'documents': {
164             'source_filenames': (
165                 'css/filelist.css',
166             ),
167             'output_filename': 'compressed/documents_styles.css',
168         },
169         'book': {
170             'source_filenames': (
171                 'css/book.css',
172             ),
173             'output_filename': 'compressed/book.css',
174         },
175         'book_list': {
176             'source_filenames': (
177                 'css/book_list.css',
178             ),
179             'output_filename': 'compressed/book_list.css',
180         },
181     },
182     'JAVASCRIPT': {
183         # everything except codemirror
184         'detail': {
185             'source_filenames': (
186                 # libraries
187                 'js/lib/jquery/jquery.blockui.js',
188                 'js/lib/jquery/jquery.elastic.js',
189                 'js/lib/jquery/jquery.xmlns.js',
190                 'js/button_scripts.js',
191                 'js/slugify.js',
192
193                 # wiki scripts
194                 'js/wiki/caret.js',
195                 'js/wiki/wikiapi.js',
196                 'wiki/js/themes.js',
197                 'js/wiki/xslt.js',
198
199                 # base UI
200                 'js/wiki/base.js',
201                 'wiki/js/sidebar-perspective.js',
202                 'js/wiki/toolbar.js',
203
204                 # dialogs
205                 'js/wiki/dialog_save.js',
206                 'js/wiki/dialog_revert.js',
207                 'js/wiki/dialog_pubmark.js',
208
209                 # views
210                 'js/wiki/view_history.js',
211                 'js/wiki/view_summary.js',
212                 'js/wiki/view_editor_source.js',
213                 'js/wiki/view_editor_wysiwyg.js',
214                 'js/wiki/view_gallery.js',
215                 'js/wiki/view_annotations.js',
216                 'js/wiki/view_properties.js',
217                 'js/wiki/view_search.js',
218                 'js/wiki/view_column_diff.js',
219             ),
220             'output_filename': 'compressed/detail_scripts.js',
221         },
222         'wiki_img': {
223             'source_filenames': (
224                 # libraries
225                 'js/lib/jquery/jquery.blockui.js',
226                 'js/lib/jquery/jquery.elastic.js',
227                 'js/lib/jquery/jquery.imgareaselect.js',
228                 'js/button_scripts.js',
229                 'js/slugify.js',
230
231                 # wiki scripts
232                 'js/wiki_img/wikiapi.js',
233                 'wiki/js/themes.js',
234
235                 # base UI
236                 'js/wiki_img/base.js',
237                 'js/wiki/toolbar.js',
238
239                 # dialogs
240                 'js/wiki/dialog_save.js',
241                 'js/wiki/dialog_revert.js',
242                 'js/wiki/dialog_pubmark.js',
243
244                 # views
245                 'js/wiki_img/view_editor_objects.js',
246                 'js/wiki_img/view_editor_motifs.js',
247                 'js/wiki/view_editor_source.js',
248                 'js/wiki/view_history.js',
249                 'js/wiki/view_column_diff.js',
250             ),
251             'output_filename': 'compressed/detail_img_scripts.js',
252         },
253         'documents': {
254             'source_filenames': (
255                 'js/documents/documents.js',
256                 'js/slugify.js',
257                 'email_mangler/email_mangler.js',
258             ),
259             'output_filename': 'compressed/documents_scripts.js',
260         },
261         'book': {
262             'source_filenames': (
263                 'js/lib/jquery/jquery.cycle2.min.js',
264                 'js/book_text/jquery.eventdelegation.js',
265                 'js/book_text/jquery.scrollto.js',
266                 'js/book_text/jquery.highlightfade.js',
267                 'js/book_text/book.js',
268             ),
269             'output_filename': 'compressed/book.js',
270         },
271         'book_list': {
272             'source_filenames': (
273                 'js/documents/book_list.js',
274             ),
275             'output_filename': 'compressed/book_list.js',
276         }
277     }
278 }
279
280
281 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
282
283
284 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
285
286
287 REST_FRAMEWORK = {
288     'DEFAULT_AUTHENTICATION_CLASSES': [
289         'rest_framework.authentication.SessionAuthentication',
290         'redakcja.api.auth.TokenAuthentication',
291     ],
292     'DEFAULT_FILTER_BACKENDS': [
293         'django_filters.rest_framework.DjangoFilterBackend',
294         'rest_framework.filters.SearchFilter',
295     ]
296 }
297
298
299 LANGUAGES = [
300     ('pl', 'polski'),
301     ('de', 'Deutsch'),
302     ('lt', 'lietuvių'),
303 ]
304
305
306 TEST_INTEGRATION = False
307
308
309 try:
310     SENTRY_DSN
311 except NameError:
312     pass
313 else:
314     sentry_sdk.init(
315         dsn=SENTRY_DSN,
316         integrations=[DjangoIntegration()]
317     )