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