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