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