urls.py 2.85 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
        name="violation_url"),
    url(r'^attach/(?P<id>[0-9]*)$',
        view=bt.get_attach,
        name="attach"),
    # different data outputs
    url(r'^csv$',
Okhin's avatar
Okhin committed
39
        view=bt.ViolationCsvList.as_view(),
Okhin's avatar
Okhin committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
        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"),
Okhin's avatar
Okhin committed
62
63
    url(r'^lookup/',
        view=bt.LookupView.as_view(template_name='search/lookup.json'),
Okhin's avatar
Okhin committed
64
65
66
67
        name="lookup"),
    url(r'^accounts/logout$',
        'django.contrib.auth.views.logout', {'next_page': '/'}),
    url(r'^accounts/',
Okhin's avatar
Okhin committed
68
        include('registration.backends.model_activation.urls')),
Okhin's avatar
Okhin committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    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}),
    )