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