urls.py 2.48 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
fred's avatar
fred committed
18
from matos.urls import urlpatterns as matos_urlpatterns
fred's avatar
fred committed
19
from nonstop.urls import urlpatterns as nonstop_urlpatterns
20 21 22

from urls_utils import decorated_includes

fred's avatar
fred committed
23

24
sqs = SearchQuerySet().models(Emission, Episode, NewsItem).facet('categories').facet('tags')
25

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

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

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

fred's avatar
fred committed
37 38 39
    url(r'^matos/',
        decorated_includes(login_required, include(matos_urlpatterns))),

fred's avatar
fred committed
40 41 42
    url(r'^nonstop/',
        decorated_includes(login_required, include(nonstop_urlpatterns))),

43
    url(r'^newsletters/add$', 'panikdb.views.newsletter_create', name='newsletter-create'),
fred's avatar
fred committed
44 45 46
    url(r'^newsletters/',
        decorated_includes(login_required, include(newsletter_urlpatterns))),

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

49 50 51 52 53
    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
54
    url(r'^accounts/logout/', 'django.contrib.auth.views.logout_then_login', name='logout'),
55
    url(r'^accounts/', include('registration.backends.default.urls')),
56 57 58

    url(r'^admin/', include(admin.site.urls)),
)
fred's avatar
fred committed
59 60 61 62 63 64

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)