You will find only what you bring in.
[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     'django_cas_ng.middleware.CASMiddleware',
47
48     'django.contrib.admindocs.middleware.XViewMiddleware',
49     'fnp_django_pagination.middleware.PaginationMiddleware',
50     'maintenancemode.middleware.MaintenanceModeMiddleware',
51 ]
52
53 if DEBUG:
54     MIDDLEWARE = [
55         'debug_toolbar.middleware.DebugToolbarMiddleware',
56     ] + MIDDLEWARE
57
58 AUTHENTICATION_BACKENDS = (
59     'django.contrib.auth.backends.ModelBackend',
60     'django_cas_ng.backends.CASBackend',
61 )
62
63 ROOT_URLCONF = 'redakcja.urls'
64
65 INSTALLED_APPS = (
66     'django.contrib.auth',
67     'django.contrib.contenttypes',
68     'django.contrib.sessions',
69     'django.contrib.messages',
70     'django.contrib.staticfiles',
71     'django.contrib.sites',
72     'django.contrib.admin',
73     'django.contrib.admindocs',
74
75     'sorl.thumbnail',
76     'fnp_django_pagination',
77     'django_gravatar',
78     'fileupload',
79     'pipeline',
80     'fnpdjango',
81     'django_cas_ng',
82     'bootstrap4',
83
84     'catalogue',
85     'cover',
86     'dvcs',
87     'wiki',
88     'wiki_img',
89     'toolbar',
90     'apiclient',
91     'email_mangler',
92 )
93
94 if DEBUG:
95     INSTALLED_APPS += ('debug_toolbar',)
96
97 LOGIN_REDIRECT_URL = '/documents/user'
98
99 MIN_COVER_SIZE = (915, 1270)
100
101 STATICFILES_FINDERS = (
102     'django.contrib.staticfiles.finders.FileSystemFinder',
103     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
104     'pipeline.finders.PipelineFinder',
105 )
106
107 STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
108
109 PIPELINE = {
110     'CSS_COMPRESSOR': None,
111     'JS_COMPRESSOR': None,
112     'COMPILERS': (
113         'libsasscompiler.LibSassCompiler',
114     ),
115
116     # CSS and JS files to compress
117     'STYLESHEETS': {
118         'detail': {
119             'source_filenames': (
120                 'css/master.css',
121                 'css/toolbar.css',
122                 'css/gallery.css',
123                 'css/history.css',
124                 'css/summary.css',
125                 'css/html.css',
126                 'css/imgareaselect-default.css',
127                 'css/dialogs.css',
128
129                 'wiki/scss/splitter.scss',
130                 'wiki/scss/visual.scss'
131             ),
132             'output_filename': 'compressed/detail_styles.css',
133         },
134         'catalogue': {
135             'source_filenames': (
136                 'css/filelist.css',
137             ),
138             'output_filename': 'compressed/catalogue_styles.css',
139         },
140         'book': {
141             'source_filenames': (
142                 'css/book.css',
143             ),
144             'output_filename': 'compressed/book.css',
145         },
146         'book_list': {
147             'source_filenames': (
148                 'css/book_list.css',
149             ),
150             'output_filename': 'compressed/book_list.css',
151         },
152     },
153     'JAVASCRIPT': {
154         # everything except codemirror
155         'detail': {
156             'source_filenames': (
157                 # libraries
158                 'js/lib/jquery/jquery.blockui.js',
159                 'js/lib/jquery/jquery.elastic.js',
160                 'js/lib/jquery/jquery.xmlns.js',
161                 'js/button_scripts.js',
162                 'js/slugify.js',
163
164                 # wiki scripts
165                 'js/wiki/wikiapi.js',
166                 'wiki/js/themes.js',
167                 'js/wiki/xslt.js',
168
169                 # base UI
170                 'js/wiki/base.js',
171                 'wiki/js/sidebar-perspective.js',
172                 'js/wiki/toolbar.js',
173
174                 # dialogs
175                 'js/wiki/dialog_save.js',
176                 'js/wiki/dialog_revert.js',
177                 'js/wiki/dialog_pubmark.js',
178
179                 # views
180                 'js/wiki/view_history.js',
181                 'js/wiki/view_summary.js',
182                 'js/wiki/view_editor_source.js',
183                 'js/wiki/view_editor_wysiwyg.js',
184                 'js/wiki/view_gallery.js',
185                 'js/wiki/view_annotations.js',
186                 'js/wiki/view_search.js',
187                 'js/wiki/view_column_diff.js',
188             ),
189             'output_filename': 'compressed/detail_scripts.js',
190         },
191         'wiki_img': {
192             'source_filenames': (
193                 # libraries
194                 'js/lib/jquery/jquery.blockui.js',
195                 'js/lib/jquery/jquery.elastic.js',
196                 'js/lib/jquery/jquery.imgareaselect.js',
197                 'js/button_scripts.js',
198                 'js/slugify.js',
199
200                 # wiki scripts
201                 'js/wiki_img/wikiapi.js',
202                 'wiki/js/themes.js',
203
204                 # base UI
205                 'js/wiki_img/base.js',
206                 'js/wiki/toolbar.js',
207
208                 # dialogs
209                 'js/wiki/dialog_save.js',
210                 'js/wiki/dialog_revert.js',
211                 'js/wiki/dialog_pubmark.js',
212
213                 # views
214                 'js/wiki_img/view_editor_objects.js',
215                 'js/wiki_img/view_editor_motifs.js',
216                 'js/wiki/view_editor_source.js',
217                 'js/wiki/view_history.js',
218                 'js/wiki/view_column_diff.js',
219             ),
220             'output_filename': 'compressed/detail_img_scripts.js',
221         },
222         'catalogue': {
223             'source_filenames': (
224                 'js/catalogue/catalogue.js',
225                 'js/slugify.js',
226                 'email_mangler/email_mangler.js',
227             ),
228             'output_filename': 'compressed/catalogue_scripts.js',
229         },
230         'book': {
231             'source_filenames': (
232                 'js/book_text/jquery.eventdelegation.js',
233                 'js/book_text/jquery.scrollto.js',
234                 'js/book_text/jquery.highlightfade.js',
235                 'js/book_text/book.js',
236             ),
237             'output_filename': 'compressed/book.js',
238         },
239         'book_list': {
240             'source_filenames': (
241                 'js/catalogue/book_list.js',
242             ),
243             'output_filename': 'compressed/book_list.js',
244         }
245     }
246 }
247
248
249 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
250
251
252 try:
253     SENTRY_DSN
254 except NameError:
255     pass
256 else:
257     sentry_sdk.init(
258         dsn=SENTRY_DSN,
259         integrations=[DjangoIntegration()]
260     )