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