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