urls.py 2.17 KB
Newer Older
1
from django.conf.urls import patterns, include, url
fred's avatar
fred committed
2
from django.conf import settings
fred's avatar
fred committed
3 4
from django.views.generic import RedirectView
from django.core.urlresolvers import reverse_lazy
5
from django.contrib.auth.decorators import login_required
6 7 8 9

from django.contrib import admin
admin.autodiscover()

fred's avatar
fred committed
10
from haystack.views import search_view_factory
fred's avatar
fred committed
11 12 13
from haystack.forms import FacetedSearchForm
from haystack.query import SearchQuerySet

fred's avatar
fred committed
14
from emissions.views import FacetedSearchView
fred's avatar
fred committed
15
from emissions.urls import urlpatterns as emissions_urlpatterns
16
from emissions.models import Emission, Episode, NewsItem
fred's avatar
fred committed
17
from newsletter.urls import management_patterns as newsletter_urlpatterns
18 19 20

from urls_utils import decorated_includes

fred's avatar
fred committed
21

22
sqs = SearchQuerySet().models(Emission, Episode, NewsItem).facet('categories').facet('tags')
23

24
urlpatterns = patterns('',
fred's avatar
fred committed
25
    url(r'^$', 'panikdb.views.home', name='home'),
26
    (r'^ckeditor/', include('ckeditor.urls')),
fred's avatar
fred committed
27 28
    url(r'^search/', search_view_factory(view_class=FacetedSearchView,
        form_class=FacetedSearchForm, searchqueryset=sqs), name='haystack_search'),
29

fred's avatar
fred committed
30
    url(r'^emissions/$', 'panikdb.views.emissions', name='emission-list'),
31 32 33 34

    url(r'^emissions/',
        decorated_includes(login_required, include(emissions_urlpatterns))),

35
    url(r'^newsletters/add$', 'panikdb.views.newsletter_create', name='newsletter-create'),
fred's avatar
fred committed
36 37 38
    url(r'^newsletters/',
        decorated_includes(login_required, include(newsletter_urlpatterns))),

fred's avatar
fred committed
39 40
    url(r'^news/$', 'panikdb.views.news', name='news-list'),

41 42 43 44 45
    url(r'^focus/set/(?P<object_type>[\w,-]+)/(?P<object_id>\d+)$',
        'panikdb.views.focus_set', name='focus-set'),
    url(r'^focus/unset/(?P<object_type>[\w,-]+)/(?P<object_id>\d+)$',
        'panikdb.views.focus_unset', name='focus-unset'),

fred's avatar
fred committed
46
    url(r'^accounts/logout/', 'django.contrib.auth.views.logout_then_login', name='logout'),
47
    url(r'^accounts/', include('registration.backends.default.urls')),
48 49 50

    url(r'^admin/', include(admin.site.urls)),
)
fred's avatar
fred committed
51 52 53 54 55 56

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()

from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)