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