urls.py 2.54 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

9
admin.autodiscover()
10 11

urlpatterns = patterns('',
12 13 14 15 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'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$',
        view=bt.ajax,
        name="ajax_call"),
    url(r'^add/$',
        view=bt.add,
        name="add"),
27 28 29 30
    # violation cannonical url and redirections
    url(r'^(?P<id>[0-9]*)$',
        redirect_to,
        {'url': '/view/%(id)s'}),
31 32
    url(r'^view/(?P<id>[0-9]*)$',
        view=bt.view,
33
        name="violation_url"),
34 35 36
    url(r'^attach/(?P<id>[0-9]*)$',
        view=bt.get_attach,
        name="attach"),
37
    # different data outputs
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    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)),
81 82 83 84
)

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