46b80da1b8327375cff357a24bbe2f505ba9bc50
[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     'maintenancemode.middleware.MaintenanceModeMiddleware',
57 ]
58
59 if DEBUG:
60     MIDDLEWARE = [
61         'debug_toolbar.middleware.DebugToolbarMiddleware',
62     ] + MIDDLEWARE
63
64 if CAS_SERVER_URL:
65     AUTHENTICATION_BACKENDS = (
66         'django.contrib.auth.backends.ModelBackend',
67         'django_cas_ng.backends.CASBackend',
68     )
69
70 ROOT_URLCONF = 'redakcja.urls'
71
72 INSTALLED_APPS = (
73     'django.contrib.auth',
74     'django.contrib.contenttypes',
75     'django.contrib.sessions',
76     'django.contrib.messages',
77     'django.contrib.staticfiles',
78     'django.contrib.sites',
79     'admin_numeric_filter',
80     'django.contrib.admin',
81     'django.contrib.admindocs',
82
83     'sorl.thumbnail',
84     'fnp_django_pagination',
85     'django_gravatar',
86     'fileupload',
87     'pipeline',
88     'fnpdjango',
89     'django_cas_ng',
90     'bootstrap4',
91     'rest_framework',
92     'django_filters',
93
94     'redakcja.api',
95     'catalogue',
96     'depot',
97     'documents',
98     'cover',
99     'dvcs',
100     'wiki',
101     'wiki_img',
102     'toolbar',
103     'apiclient',
104     'email_mangler',
105     'wlxml.apps.WlxmlConfig',
106 )
107
108 if DEBUG:
109     INSTALLED_APPS += ('debug_toolbar',)
110
111 LOCALE_PATHS = [
112     PROJECT_ROOT + "/locale-contrib",
113 ]
114
115 LOGIN_REDIRECT_URL = '/documents/user'
116
117 MIN_COVER_SIZE = (915, 1270)
118
119 STATICFILES_FINDERS = (
120     'django.contrib.staticfiles.finders.FileSystemFinder',
121     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
122     'pipeline.finders.PipelineFinder',
123 )
124
125 STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
126
127 PIPELINE = {
128     'CSS_COMPRESSOR': None,
129     'JS_COMPRESSOR': None,
130     'COMPILERS': (
131         'pipeline.compilers.sass.SASSCompiler',
132     ),
133
134     # CSS and JS files to compress
135     'STYLESHEETS': {
136         'detail': {
137             'source_filenames': (
138                 'css/master.css',
139                 'css/toolbar.css',
140                 'css/gallery.css',
141                 'css/history.css',
142                 'css/summary.css',
143                 'css/html.scss',
144                 'css/imgareaselect-default.css',
145                 'css/dialogs.css',
146
147                 'wiki/scss/splitter.scss',
148                 'wiki/scss/visual.scss'
149             ),
150             'output_filename': 'compressed/detail_styles.css',
151         },
152         'documents': {
153             'source_filenames': (
154                 'css/filelist.css',
155             ),
156             'output_filename': 'compressed/documents_styles.css',
157         },
158         'book': {
159             'source_filenames': (
160                 'css/book.css',
161             ),
162             'output_filename': 'compressed/book.css',
163         },
164         'book_list': {
165             'source_filenames': (
166                 'css/book_list.css',
167             ),
168             'output_filename': 'compressed/book_list.css',
169         },
170     },
171     'JAVASCRIPT': {
172         # everything except codemirror
173         'detail': {
174             'source_filenames': (
175                 # libraries
176                 'js/lib/jquery/jquery.blockui.js',
177                 'js/lib/jquery/jquery.elastic.js',
178                 'js/lib/jquery/jquery.xmlns.js',
179                 'js/button_scripts.js',
180                 'js/slugify.js',
181
182                 # wiki scripts
183                 'js/wiki/caret.js',
184                 'js/wiki/wikiapi.js',
185                 'wiki/js/themes.js',
186                 'js/wiki/xslt.js',
187
188                 # base UI
189                 'js/wiki/base.js',
190                 'wiki/js/sidebar-perspective.js',
191                 'js/wiki/toolbar.js',
192
193                 # dialogs
194                 'js/wiki/dialog_save.js',
195                 'js/wiki/dialog_revert.js',
196                 'js/wiki/dialog_pubmark.js',
197
198                 # views
199                 'js/wiki/view_history.js',
200                 'js/wiki/view_summary.js',
201                 'js/wiki/view_editor_source.js',
202                 'js/wiki/view_editor_wysiwyg.js',
203                 'js/wiki/view_gallery.js',
204                 'js/wiki/view_annotations.js',
205                 'js/wiki/view_properties.js',
206                 'js/wiki/view_search.js',
207                 'js/wiki/view_column_diff.js',
208             ),
209             'output_filename': 'compressed/detail_scripts.js',
210         },
211         'wiki_img': {
212             'source_filenames': (
213                 # libraries
214                 'js/lib/jquery/jquery.blockui.js',
215                 'js/lib/jquery/jquery.elastic.js',
216                 'js/lib/jquery/jquery.imgareaselect.js',
217                 'js/button_scripts.js',
218                 'js/slugify.js',
219
220                 # wiki scripts
221                 'js/wiki_img/wikiapi.js',
222                 'wiki/js/themes.js',
223
224                 # base UI
225                 'js/wiki_img/base.js',
226                 'js/wiki/toolbar.js',
227
228                 # dialogs
229                 'js/wiki/dialog_save.js',
230                 'js/wiki/dialog_revert.js',
231                 'js/wiki/dialog_pubmark.js',
232
233                 # views
234                 'js/wiki_img/view_editor_objects.js',
235                 'js/wiki_img/view_editor_motifs.js',
236                 'js/wiki/view_editor_source.js',
237                 'js/wiki/view_history.js',
238                 'js/wiki/view_column_diff.js',
239             ),
240             'output_filename': 'compressed/detail_img_scripts.js',
241         },
242         'documents': {
243             'source_filenames': (
244                 'js/documents/documents.js',
245                 'js/slugify.js',
246                 'email_mangler/email_mangler.js',
247             ),
248             'output_filename': 'compressed/documents_scripts.js',
249         },
250         'book': {
251             'source_filenames': (
252                 'js/lib/jquery/jquery.cycle2.min.js',
253                 'js/book_text/jquery.eventdelegation.js',
254                 'js/book_text/jquery.scrollto.js',
255                 'js/book_text/jquery.highlightfade.js',
256                 'js/book_text/book.js',
257             ),
258             'output_filename': 'compressed/book.js',
259         },
260         'book_list': {
261             'source_filenames': (
262                 'js/documents/book_list.js',
263             ),
264             'output_filename': 'compressed/book_list.js',
265         }
266     }
267 }
268
269
270 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
271
272
273 REST_FRAMEWORK = {
274     'DEFAULT_AUTHENTICATION_CLASSES': [
275         'rest_framework.authentication.SessionAuthentication',
276         'redakcja.api.auth.TokenAuthentication',
277     ],
278     'DEFAULT_FILTER_BACKENDS': [
279         'django_filters.rest_framework.DjangoFilterBackend',
280         'rest_framework.filters.SearchFilter',
281     ]
282 }
283
284
285 try:
286     SENTRY_DSN
287 except NameError:
288     pass
289 else:
290     sentry_sdk.init(
291         dsn=SENTRY_DSN,
292         integrations=[DjangoIntegration()]
293     )