95956d9e9b8f30a04d532e89d576fe5c3c231e5d
[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 STATICFILES_FINDERS = (
129     'django.contrib.staticfiles.finders.FileSystemFinder',
130     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
131     'pipeline.finders.PipelineFinder',
132 )
133
134 STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
135
136 PIPELINE = {
137     'CSS_COMPRESSOR': None,
138     'JS_COMPRESSOR': None,
139     'COMPILERS': (
140         'pipeline.compilers.sass.SASSCompiler',
141     ),
142
143     # CSS and JS files to compress
144     'STYLESHEETS': {
145         'detail': {
146             'source_filenames': (
147                 'css/master.css',
148                 'css/toolbar.css',
149                 'css/gallery.css',
150                 'css/history.css',
151                 'css/summary.css',
152                 'css/html.scss',
153                 'css/imgareaselect-default.css',
154                 'css/dialogs.css',
155
156                 'wiki/scss/splitter.scss',
157                 'wiki/scss/visual.scss'
158             ),
159             'output_filename': 'compressed/detail_styles.css',
160         },
161         'documents': {
162             'source_filenames': (
163                 'css/filelist.css',
164             ),
165             'output_filename': 'compressed/documents_styles.css',
166         },
167         'book': {
168             'source_filenames': (
169                 'css/book.css',
170             ),
171             'output_filename': 'compressed/book.css',
172         },
173         'book_list': {
174             'source_filenames': (
175                 'css/book_list.css',
176             ),
177             'output_filename': 'compressed/book_list.css',
178         },
179     },
180     'JAVASCRIPT': {
181         # everything except codemirror
182         'detail': {
183             'source_filenames': (
184                 # libraries
185                 'js/lib/jquery/jquery.blockui.js',
186                 'js/lib/jquery/jquery.elastic.js',
187                 'js/lib/jquery/jquery.xmlns.js',
188                 'js/button_scripts.js',
189                 'js/slugify.js',
190
191                 # wiki scripts
192                 'js/wiki/caret.js',
193                 'js/wiki/wikiapi.js',
194                 'wiki/js/themes.js',
195                 'js/wiki/xslt.js',
196
197                 # base UI
198                 'js/wiki/base.js',
199                 'wiki/js/sidebar-perspective.js',
200                 'js/wiki/toolbar.js',
201
202                 # dialogs
203                 'js/wiki/dialog_save.js',
204                 'js/wiki/dialog_revert.js',
205                 'js/wiki/dialog_pubmark.js',
206
207                 # views
208                 'js/wiki/view_history.js',
209                 'js/wiki/view_summary.js',
210                 'js/wiki/view_editor_source.js',
211                 'js/wiki/view_editor_wysiwyg.js',
212                 'js/wiki/view_gallery.js',
213                 'js/wiki/view_annotations.js',
214                 'js/wiki/view_properties.js',
215                 'js/wiki/view_search.js',
216                 'js/wiki/view_column_diff.js',
217             ),
218             'output_filename': 'compressed/detail_scripts.js',
219         },
220         'wiki_img': {
221             'source_filenames': (
222                 # libraries
223                 'js/lib/jquery/jquery.blockui.js',
224                 'js/lib/jquery/jquery.elastic.js',
225                 'js/lib/jquery/jquery.imgareaselect.js',
226                 'js/button_scripts.js',
227                 'js/slugify.js',
228
229                 # wiki scripts
230                 'js/wiki_img/wikiapi.js',
231                 'wiki/js/themes.js',
232
233                 # base UI
234                 'js/wiki_img/base.js',
235                 'js/wiki/toolbar.js',
236
237                 # dialogs
238                 'js/wiki/dialog_save.js',
239                 'js/wiki/dialog_revert.js',
240                 'js/wiki/dialog_pubmark.js',
241
242                 # views
243                 'js/wiki_img/view_editor_objects.js',
244                 'js/wiki_img/view_editor_motifs.js',
245                 'js/wiki/view_editor_source.js',
246                 'js/wiki/view_history.js',
247                 'js/wiki/view_column_diff.js',
248             ),
249             'output_filename': 'compressed/detail_img_scripts.js',
250         },
251         'documents': {
252             'source_filenames': (
253                 'js/documents/documents.js',
254                 'js/slugify.js',
255                 'email_mangler/email_mangler.js',
256             ),
257             'output_filename': 'compressed/documents_scripts.js',
258         },
259         'book': {
260             'source_filenames': (
261                 'js/lib/jquery/jquery.cycle2.min.js',
262                 'js/book_text/jquery.eventdelegation.js',
263                 'js/book_text/jquery.scrollto.js',
264                 'js/book_text/jquery.highlightfade.js',
265                 'js/book_text/book.js',
266             ),
267             'output_filename': 'compressed/book.js',
268         },
269         'book_list': {
270             'source_filenames': (
271                 'js/documents/book_list.js',
272             ),
273             'output_filename': 'compressed/book_list.js',
274         }
275     }
276 }
277
278
279 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
280
281
282 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
283
284
285 REST_FRAMEWORK = {
286     'DEFAULT_AUTHENTICATION_CLASSES': [
287         'rest_framework.authentication.SessionAuthentication',
288         'redakcja.api.auth.TokenAuthentication',
289     ],
290     'DEFAULT_FILTER_BACKENDS': [
291         'django_filters.rest_framework.DjangoFilterBackend',
292         'rest_framework.filters.SearchFilter',
293     ]
294 }
295
296
297 LANGUAGES = [
298     ('pl', 'polski'),
299     ('de', 'Deutsch'),
300     ('lt', 'lietuvių'),
301 ]
302
303
304 TEST_INTEGRATION = False
305
306
307 try:
308     SENTRY_DSN
309 except NameError:
310     pass
311 else:
312     sentry_sdk.init(
313         dsn=SENTRY_DSN,
314         integrations=[DjangoIntegration()]
315     )