ce3289b04051ff9b648c58855410643333cce2e4
[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                 'js/wiki/toolbar.js',
202                 'js/lib/diff.js',
203                 'js/wiki/undo.js',
204
205                 # dialogs
206                 'js/wiki/dialog_save.js',
207                 'js/wiki/dialog_revert.js',
208                 'js/wiki/dialog_pubmark.js',
209
210                 # views
211                 'js/wiki/view_sidebar.js',
212                 'js/wiki/view_history.js',
213                 'js/wiki/view_summary.js',
214                 'js/wiki/view_editor_source.js',
215                 'js/wiki/view_editor_wysiwyg.js',
216                 'js/wiki/view_gallery.js',
217                 'js/wiki/view_annotations.js',
218                 'js/wiki/view_properties.js',
219                 'js/wiki/view_search.js',
220                 'js/wiki/view_column_diff.js',
221             ),
222             'output_filename': 'compressed/detail_scripts.js',
223         },
224         'wiki_img': {
225             'source_filenames': (
226                 # libraries
227                 'js/lib/jquery/jquery.blockui.js',
228                 'js/lib/jquery/jquery.elastic.js',
229                 'js/lib/jquery/jquery.imgareaselect.js',
230                 'js/button_scripts.js',
231                 'js/slugify.js',
232
233                 # wiki scripts
234                 'js/wiki_img/wikiapi.js',
235                 'wiki/js/themes.js',
236
237                 # base UI
238                 'js/wiki_img/base.js',
239                 'js/wiki/toolbar.js',
240
241                 # dialogs
242                 'js/wiki/dialog_save.js',
243                 'js/wiki/dialog_revert.js',
244                 'js/wiki/dialog_pubmark.js',
245
246                 # views
247                 'js/wiki_img/view_editor_objects.js',
248                 'js/wiki_img/view_editor_motifs.js',
249                 'js/wiki/view_editor_source.js',
250                 'js/wiki/view_history.js',
251                 'js/wiki/view_column_diff.js',
252             ),
253             'output_filename': 'compressed/detail_img_scripts.js',
254         },
255         'documents': {
256             'source_filenames': (
257                 'js/documents/documents.js',
258                 'js/slugify.js',
259                 'email_mangler/email_mangler.js',
260             ),
261             'output_filename': 'compressed/documents_scripts.js',
262         },
263         'book': {
264             'source_filenames': (
265                 'js/lib/jquery/jquery.cycle2.min.js',
266                 'js/book_text/jquery.eventdelegation.js',
267                 'js/book_text/jquery.scrollto.js',
268                 'js/book_text/jquery.highlightfade.js',
269                 'js/book_text/book.js',
270             ),
271             'output_filename': 'compressed/book.js',
272         },
273         'book_list': {
274             'source_filenames': (
275                 'js/documents/book_list.js',
276             ),
277             'output_filename': 'compressed/book_list.js',
278         }
279     }
280 }
281
282
283 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
284
285
286 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
287
288
289 REST_FRAMEWORK = {
290     'DEFAULT_AUTHENTICATION_CLASSES': [
291         'rest_framework.authentication.SessionAuthentication',
292         'redakcja.api.auth.TokenAuthentication',
293     ],
294     'DEFAULT_FILTER_BACKENDS': [
295         'django_filters.rest_framework.DjangoFilterBackend',
296         'rest_framework.filters.SearchFilter',
297     ]
298 }
299
300
301 LANGUAGES = [
302     ('pl', 'polski'),
303     ('de', 'Deutsch'),
304     ('lt', 'lietuvių'),
305 ]
306
307
308 TEST_INTEGRATION = False
309
310
311 try:
312     SENTRY_DSN
313 except NameError:
314     pass
315 else:
316     sentry_sdk.init(
317         dsn=SENTRY_DSN,
318         integrations=[DjangoIntegration()]
319     )