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