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