urls.py 2.77 KB
Newer Older
Okhin's avatar
Okhin committed
1 2 3 4 5 6
from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView, RedirectView
from django.conf import settings
from django.contrib import admin
from bt import views as bt
from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
Okhin's avatar
Okhin committed
7

Okhin's avatar
Okhin committed
8 9 10 11 12 13 14 15 16
from bt.api import APIResource, OperatorResource

api_resource = APIResource()
operator_api_resource = OperatorResource()

admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$',
17
        view=bt.AddForm.as_view(),
Okhin's avatar
Okhin committed
18 19
        name="homepage"),
    url(r'^list/$',
20
        view=bt.ViolationsList.as_view(),
Okhin's avatar
Okhin committed
21
        name="list_violations"),
22
    url(r'^list/(?P<country>\w+)/$',
23
        view=bt.ViolationsList.as_view(),
24 25 26 27
        name="filter_country"),
    url(r'^list/(?P<country>\w+)/(?P<operator>\w+)/$',
        view=bt.ViolationsList.as_view(),
        name="filter_operator"),
Okhin's avatar
Okhin committed
28 29 30 31
    # violation cannonical url and redirections
    url(r'^(?P<id>[0-9]*)$',
        RedirectView.as_view(url='/view/%(id)s')),
    url(r'^view/(?P<id>[0-9]*)$',
32
        view=bt.ViolationView.as_view(),
Okhin's avatar
Okhin committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
        name="violation_url"),
    url(r'^attach/(?P<id>[0-9]*)$',
        view=bt.get_attach,
        name="attach"),
    # different data outputs
    url(r'^csv$',
        view=bt.ascsv,
        name="csv_output"),
    url(r'^ods$',
        view=bt.asods,
        name="ods_output"),
    url(r'^rss/$',
        view=RssSiteNewsFeed(),
        name="rss_output"),
    url(r'^atom/$',
        view=AtomSiteNewsFeed(),
        name="atom_output"),
    url(r'^activate/$',
        view=bt.activate,
        name="activate"),
    url(r'^confirm/(?P<id>[0-9a-z]*)$',
        view=bt.confirm,
        name="confirm"),
    url(r'^confirm/(?P<id>[0-9]*)/(?P<name>.*)$',
        view=bt.confirm,
        name="confirm_full"),
    url(r'^moderate/$',
        view=bt.moderate,
        name="moderate"),
    url(r'^lookup/$',
63
        view=bt.LookupView.as_view(),
Okhin's avatar
Okhin committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        name="lookup"),
    url(r'^accounts/logout$',
        'django.contrib.auth.views.logout', {'next_page': '/'}),
    url(r'^accounts/',
        include('registration.urls')),
    url(r'^comments/',
        include('django_comments.urls')),
    url(r'^about/$',
        TemplateView.as_view(template_name='nn.html')),
    url(r'^start/$',
        TemplateView.as_view(template_name='start.html')),
    url(r'^captcha/',
        include('captcha.urls')),
    url(r'^admin/',
        include(admin.site.urls)),
    url(r'^api/',
        include(api_resource.urls)),
    url(r'^api/',
        include(operator_api_resource.urls)),
Okhin's avatar
Okhin committed
83
    url(r'^search/',
84
        bt.ViolationSearchView.as_view(template_name='search/search.html')),
Okhin's avatar
Okhin committed
85 86 87 88 89 90 91 92
)

if settings.DEV_SERVER == True:
    urlpatterns += patterns('',
        (r'^site_media/(?P<path>.*)$',
            'django.views.static.serve',
            {'document_root': settings.MEDIA_PATH}),
    )