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