ccb9fcf7c4493ee872bcc59bb0aada8d0b47b0f8
[redakcja.git] / platforma / urls.py
1 # -*- coding: utf-8 -*-
2
3 from django.conf.urls.defaults import *
4 from django.contrib import admin
5 from django.conf import settings
6
7 admin.autodiscover()
8 PATH_SEC = r"(?P<path>[^/]+)"
9 PATH_END = PATH_SEC + "/$"
10
11 urlpatterns = patterns('',
12     # Explorer:
13     url(r'^$', 'explorer.views.file_list', name='file_list'),        
14     url(r'^file/upload', 'explorer.views.file_upload', name='file_upload'),    
15
16     url(r'^management/pull-requests$', 'explorer.views.pull_requests'),
17   
18     # Editor panels
19     url(r'^editor/'+PATH_END, 'explorer.views.display_editor', name='editor_view'),
20     url(r'^editor/$', 'explorer.views.file_list', name='editor_base'),
21
22     url(r'^file/(?P<docid>[^/]+)/print$', 'explorer.views.print_html', name="file_print"),
23
24     # Admin panel
25     (r'^admin/filebrowser/', include('filebrowser.urls')),
26     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
27     url(r'^admin/(.*)', admin.site.root),
28
29     # Theme database
30     url(r'themes/', include('bookthemes.urls')),
31
32     # Our über-restful api
33     url(r'^api/', include('api.urls')),
34     
35 )
36
37 if 'cas_consumer' in settings.INSTALLED_APPS:
38     urlpatterns += patterns('',
39         # django-cas-consumer
40         url(r'^accounts/login/$', 'cas_consumer.views.login', name='login'),
41         url(r'^accounts/logout/$', 'cas_consumer.views.logout', name='logout'),
42     )
43 else:
44     urlpatterns += patterns('',
45         # Django auth
46         url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'redirect_field_name': 'next'}, name='login'),
47         url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='logout'),    
48     )
49
50 # Static files
51 if settings.DEBUG:
52     urlpatterns += patterns('',
53         url(r'^renderer$', 'explorer.views.renderer_test'),
54     )
55
56     if not hasattr(settings, 'DONT_SERVE_STATIC'):
57         urlpatterns += patterns('',
58             url(r'^%s(?P<path>.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
59                 {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
60             url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
61                 {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
62         )