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