urls.py 1.85 KB
Newer Older
1
from django.conf.urls.defaults import *
christophe siraut's avatar
christophe siraut committed
2
from django.contrib.auth.views import login, logout
chris's avatar
chris committed
3
4
from sondage.models import Poll
from sondage.forms import PollForm
5
6

# Uncomment the next two lines to enable the admin:
chris's avatar
chris committed
7
8
from django.contrib import admin
admin.autodiscover()
9

christophe siraut's avatar
christophe siraut committed
10
11
12
13
14
15
16
17
18
19
20

info_dict = {
    'queryset': Poll.objects.all(),
}

poll_dict = {
    #'model' : Poll,
    'form_class' : PollForm,
    'post_save_redirect' : '/'
}

21
22
23
24
urlpatterns = patterns('',
    # Example:
    # (r'^nuage/', include('nuage.foo.urls')),

chris's avatar
chris committed
25
26
    (r'^admin/', include(admin.site.urls)),
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
christophe siraut's avatar
christophe siraut committed
27
28

    (r'^$', 'django.views.generic.list_detail.object_list', dict(info_dict, template_name='index.html')),
29
    (r'^nuages$', 'django.views.generic.simple.direct_to_template', {'template': 'nuages.html'}),
chris's avatar
chris committed
30
31
32
33
34
35
    (r'^(?P<poll_id>\w{4})/$', 'sondage.views.vote'),
    (r'^new/$', 'sondage.views.new'),
    (r'^(?P<object_id>\w+)/edit/$', 'sondage.views.secure_update_object', dict(poll_dict, post_save_redirect='choices/')),
    (r'^(?P<poll_id>\w+)/delete/$', 'sondage.views.delete'),
    (r'^(?P<poll_id>\w+)/edit/choices/$', 'sondage.views.editchoices'),
    (r'^(?P<poll_id>\w{4})/vote/$', 'sondage.views.vote'),
christophe siraut's avatar
christophe siraut committed
36
37
38

    (r'^user/login/$',  login),
    (r'^user/logout/$', logout, {'template_name': 'index.html'}),
chris's avatar
chris committed
39
    (r'^user/register', 'sondage.userviews.register'),
40
    (r'^user/success$', 'django.views.generic.simple.direct_to_template', {'template': 'registration/success.html'}),
christophe siraut's avatar
christophe siraut committed
41

42
    (r'^i18n/', include('django.conf.urls.i18n')),
chris's avatar
chris committed
43
    (r'^(?P<poll_id>\w{4})/clear/', 'sondage.userviews.clear_cookie'),
44
)
christophe siraut's avatar
christophe siraut committed
45
46
47
48
49
50
51
52
53
54
55


from django.conf import settings

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^%s/(?P<path>.*)$' % settings.MEDIA_URL[1:-1],
         'django.views.static.serve',
         {'document_root':  settings.MEDIA_ROOT, 'show_indexes': False}),
    )