61f2be53c349f849a9f58d4f78756a45cf2a6e86
[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 PROJECT_ROOT = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
11
12 STATICFILES_DIRS = [
13     PROJECT_ROOT + '/static/'
14 ]
15
16 TEMPLATES = [
17     {
18         'BACKEND': 'django.template.backends.django.DjangoTemplates',
19         'APP_DIRS': True,
20         'DIRS': [
21             PROJECT_ROOT + '/templates',
22         ],
23         'OPTIONS': {
24             'context_processors': [
25                 "django.contrib.auth.context_processors.auth",
26                 "django.template.context_processors.debug",
27                 "django.template.context_processors.i18n",
28                 "redakcja.context_processors.settings", # this is instead of media
29                 'django.template.context_processors.csrf',
30                 "django.template.context_processors.request",
31                 "django.contrib.messages.context_processors.messages",
32             ],
33         },
34     },
35 ]
36
37 MIDDLEWARE = [
38     'django.middleware.common.CommonMiddleware',
39     'django.middleware.csrf.CsrfViewMiddleware',
40     'django.contrib.sessions.middleware.SessionMiddleware',
41     'django.contrib.messages.middleware.MessageMiddleware',
42
43     'django.contrib.auth.middleware.AuthenticationMiddleware',
44     'django_cas_ng.middleware.CASMiddleware',
45
46     'django.contrib.admindocs.middleware.XViewMiddleware',
47     'fnp_django_pagination.middleware.PaginationMiddleware',
48     'maintenancemode.middleware.MaintenanceModeMiddleware',
49 ]
50
51 if DEBUG:
52     MIDDLEWARE = [
53         'debug_toolbar.middleware.DebugToolbarMiddleware',
54     ] + MIDDLEWARE
55
56 AUTHENTICATION_BACKENDS = (
57     'django.contrib.auth.backends.ModelBackend',
58     'django_cas_ng.backends.CASBackend',
59 )
60
61 ROOT_URLCONF = 'redakcja.urls'
62
63 INSTALLED_APPS = (
64     'django.contrib.auth',
65     'django.contrib.contenttypes',
66     'django.contrib.sessions',
67     'django.contrib.messages',
68     'django.contrib.staticfiles',
69     'django.contrib.sites',
70     'django.contrib.admin',
71     'django.contrib.admindocs',
72
73     'sorl.thumbnail',
74     'fnp_django_pagination',
75     'django_gravatar',
76     'fileupload',
77     'pipeline',
78     'fnpdjango',
79     'django_cas_ng',
80     'bootstrap4',
81
82     'catalogue',
83     'cover',
84     'dvcs',
85     'wiki',
86     'wiki_img',
87     'toolbar',
88     'apiclient',
89     'email_mangler',
90 )
91
92 if DEBUG:
93     INSTALLED_APPS += ('debug_toolbar',)
94
95 LOGIN_REDIRECT_URL = '/documents/user'
96
97 MIN_COVER_SIZE = (915, 1270)
98
99 STATICFILES_FINDERS = (
100     'django.contrib.staticfiles.finders.FileSystemFinder',
101     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
102     'pipeline.finders.PipelineFinder',
103 )
104
105 STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
106
107 PIPELINE = {
108     'CSS_COMPRESSOR': None,
109     'JS_COMPRESSOR': None,
110
111     # CSS and JS files to compress
112     'STYLESHEETS': {
113         'detail': {
114             'source_filenames': (
115                 'css/master.css',
116                 'css/toolbar.css',
117                 'css/gallery.css',
118                 'css/history.css',
119                 'css/summary.css',
120                 'css/html.css',
121                 'css/jquery.autocomplete.css',
122                 'css/imgareaselect-default.css',
123                 'css/dialogs.css',
124             ),
125             'output_filename': 'compressed/detail_styles.css',
126         },
127         'catalogue': {
128             'source_filenames': (
129                 'css/filelist.css',
130             ),
131             'output_filename': 'compressed/catalogue_styles.css',
132         },
133         'book': {
134             'source_filenames': (
135                 'css/book.css',
136             ),
137             'output_filename': 'compressed/book.css',
138         },
139         'book_list': {
140             'source_filenames': (
141                 'contextmenu/jquery.contextMenu.css',
142                 'css/book_list.css',
143             ),
144             'output_filename': 'compressed/book_list.css',
145         },
146     },
147     'JAVASCRIPT': {
148         # everything except codemirror
149         'detail': {
150             'source_filenames': (
151                 # libraries
152                 'js/lib/jquery/jquery.autocomplete.js',
153                 'js/lib/jquery/jquery.blockui.js',
154                 'js/lib/jquery/jquery.elastic.js',
155                 'js/lib/jquery/jquery.xmlns.js',
156                 'js/button_scripts.js',
157                 'js/slugify.js',
158
159                 # wiki scripts
160                 'js/wiki/wikiapi.js',
161                 'js/wiki/xslt.js',
162
163                 # base UI
164                 'js/wiki/base.js',
165                 'js/wiki/toolbar.js',
166
167                 # dialogs
168                 'js/wiki/dialog_save.js',
169                 'js/wiki/dialog_revert.js',
170                 'js/wiki/dialog_pubmark.js',
171
172                 # views
173                 'js/wiki/view_history.js',
174                 'js/wiki/view_summary.js',
175                 'js/wiki/view_editor_source.js',
176                 'js/wiki/view_editor_wysiwyg.js',
177                 'js/wiki/view_gallery.js',
178                 'js/wiki/view_annotations.js',
179                 'js/wiki/view_search.js',
180                 'js/wiki/view_column_diff.js',
181             ),
182             'output_filename': 'compressed/detail_scripts.js',
183         },
184         'wiki_img': {
185             'source_filenames': (
186                 # libraries
187                 'js/lib/jquery-1.4.2.min.js',
188                 'js/lib/jquery/jquery.autocomplete.js',
189                 'js/lib/jquery/jquery.blockui.js',
190                 'js/lib/jquery/jquery.elastic.js',
191                 'js/lib/jquery/jquery.imgareaselect.js',
192                 'js/button_scripts.js',
193                 'js/slugify.js',
194
195                 # wiki scripts
196                 'js/wiki_img/wikiapi.js',
197
198                 # base UI
199                 'js/wiki_img/base.js',
200                 'js/wiki/toolbar.js',
201
202                 # dialogs
203                 'js/wiki/dialog_save.js',
204                 'js/wiki/dialog_revert.js',
205                 'js/wiki/dialog_pubmark.js',
206
207                 # views
208                 'js/wiki_img/view_editor_objects.js',
209                 'js/wiki_img/view_editor_motifs.js',
210                 'js/wiki/view_editor_source.js',
211                 'js/wiki/view_history.js',
212                 'js/wiki/view_column_diff.js',
213             ),
214             'output_filename': 'compressed/detail_img_scripts.js',
215         },
216         'catalogue': {
217             'source_filenames': (
218                 'js/catalogue/catalogue.js',
219                 'js/slugify.js',
220                 'email_mangler/email_mangler.js',
221             ),
222             'output_filename': 'compressed/catalogue_scripts.js',
223         },
224         'book': {
225             'source_filenames': (
226                 'js/book_text/jquery.eventdelegation.js',
227                 'js/book_text/jquery.scrollto.js',
228                 'js/book_text/jquery.highlightfade.js',
229                 'js/book_text/book.js',
230             ),
231             'output_filename': 'compressed/book.js',
232         },
233         'book_list': {
234             'source_filenames': (
235                 'contextmenu/jquery.ui.position.js',
236                 'contextmenu/jquery.contextMenu.js',
237                 'js/catalogue/book_list.js',
238             ),
239             'output_filename': 'compressed/book_list.js',
240         }
241     }
242 }
243
244
245 try:
246     SENTRY_DSN
247 except NameError:
248     pass
249 else:
250     sentry_sdk.init(
251         dsn=SENTRY_DSN,
252         integrations=[DjangoIntegration()]
253     )