318d97cc55ed84468f8f4fca7c342b967dbbef76
[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'^renderer$', 'explorer.views.renderer_test'),
17
18     url(r'^management/pull-requests$', 'explorer.views.pull_requests'),
19   
20     # Editor panels
21     url(r'^editor/'+PATH_END, 'explorer.views.display_editor', name='editor_view'),
22     url(r'^editor/$', 'explorer.views.file_list', name='editor_base'),
23
24     url(r'^file/(?P<docid>[^/]+)/print$', 'explorer.views.print_html', name="file_print"),
25
26     # Admin panel
27     (r'^admin/filebrowser/', include('filebrowser.urls')),
28     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
29     url(r'^admin/(.*)', admin.site.root),
30
31     # Theme database
32     url(r'themes/', include('bookthemes.urls')),
33
34     # Our über-restful api
35     url(r'^api/', include('api.urls')),
36     
37 )
38
39 if 'cas_consumer' in settings.INSTALLED_APPS:
40     urlpatterns += patterns('',
41         # django-cas-consumer
42         url(r'^accounts/login/$', 'cas_consumer.views.login', name='login'),
43         url(r'^accounts/logout/$', 'cas_consumer.views.logout', name='logout'),
44     )
45 else:
46     urlpatterns += patterns('',
47         # Django auth
48         url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'redirect_field_name': 'next'}, name='login'),
49         url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='logout'),    
50     )
51
52 # Static files
53 if settings.DEBUG and not hasattr(settings, 'DONT_SERVE_STATIC'):
54     urlpatterns += patterns('',
55         url(r'^%s(?P<path>.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
56             {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
57         url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
58             {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
59     )
60