urls.py 2.67 KB
Newer Older
1
from django.conf.urls.defaults import patterns, include, url
2
from django.views.generic.simple import direct_to_template, redirect_to
3
from django.conf import settings
4
from django.contrib import admin
5
from bt import views as bt
stef's avatar
stef committed
6
7
from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed

8
from bt.api import APIResource, OperatorResource
9
10

api_resource = APIResource()
11
operator_api_resource = OperatorResource()
12

13
admin.autodiscover()
14
15

urlpatterns = patterns('',
16
17
18
19
20
21
22
23
24
25
26
    url(r'^$',
        view=bt.index,
        name="homepage"),
    url(r'^list/$',
        view=bt.list_violations,
        name="list_violations"),
    url(r'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$',
        view=bt.filter_violations,
        name="filter"),
    url(r'^add/$',
        view=bt.add,
27
        name="add_violation"),
28
29
30
31
    # violation cannonical url and redirections
    url(r'^(?P<id>[0-9]*)$',
        redirect_to,
        {'url': '/view/%(id)s'}),
32
33
    url(r'^view/(?P<id>[0-9]*)$',
        view=bt.view,
34
        name="violation_url"),
35
36
37
    url(r'^attach/(?P<id>[0-9]*)$',
        view=bt.get_attach,
        name="attach"),
38
    # different data outputs
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    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/$',
        view=bt.lookup,
        name="lookup"),
    url(r'^accounts/logout$',
        'django.contrib.auth.views.logout', {'next_page': '/'}),
    url(r'^accounts/',
        include('registration.urls')),
    url(r'^comments/',
        include('django.contrib.comments.urls')),
    url(r'^about/$',
        direct_to_template, {'template': 'nn.html'}),
    url(r'^start/$',
        direct_to_template, {'template': 'start.html'}),
    url(r'^contact/$',
        direct_to_template, {'template': 'about.html'}),
    url(r'^captcha/',
        include('captcha.urls')),
    url(r'^admin/',
        include(admin.site.urls)),
82
83
    url(r'^api/',
        include(api_resource.urls)),
84
85
    url(r'^api/',
        include(operator_api_resource.urls)),
86
87
88
89
)

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