urls.py 8.62 KB
Newer Older
Jeremy Kerr's avatar
Jeremy Kerr committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Patchwork - automated patch tracking system
# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
#
# This file is part of the Patchwork package.
#
# Patchwork is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Patchwork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

20
from django.conf import settings
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
21
from django.conf.urls import url, include
22
from django.contrib import admin
23
from django.contrib.auth import views as auth_views
24
from rest_framework_nested import routers
25
from patchwork.views.series import SeriesListView, SeriesView
26
import patchwork.views.api as api
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
27 28 29 30 31 32 33 34
import patchwork.views
import patchwork.views.bundle
import patchwork.views.project
import patchwork.views.patch
import patchwork.views.user
import patchwork.views.mail
import patchwork.views.base
import patchwork.views.xmlrpc
35 36 37 38 39 40

# API

# /projects/$project/
project_router = routers.SimpleRouter()
project_router.register('projects', api.ProjectViewSet)
41 42 43 44
# /projects/$project/patches/
patches_list_router = routers.NestedSimpleRouter(project_router, 'projects',
                                                 lookup='project')
patches_list_router.register(r'patches', api.PatchListViewSet)
45 46 47 48
# /projects/$project/series/
series_list_router = routers.NestedSimpleRouter(project_router, 'projects',
                                                lookup='project')
series_list_router.register(r'series', api.SeriesListViewSet)
Damien Lespiau's avatar
Damien Lespiau committed
49 50 51 52
# /projects/$project/events/
event_router = routers.NestedSimpleRouter(project_router, 'projects',
                                          lookup='project')
event_router.register(r'events', api.EventLogViewSet)
53 54 55 56 57
# /series/$id/
series_router = routers.SimpleRouter()
series_router.register(r'series', api.SeriesViewSet)
# /series/$id/revisions/$rev
revisions_router = routers.NestedSimpleRouter(series_router, 'series',
58
                                              lookup='series')
59
revisions_router.register(r'revisions', api.RevisionViewSet)
60 61 62 63 64 65
# /series/$id/revisions/$rev/test-results/
revision_results_router = routers.NestedSimpleRouter(revisions_router,
                                                     'revisions',
                                                     lookup='version')
revision_results_router.register(r'test-results', api.RevisionResultViewSet,
                                 base_name='revision-results')
66 67 68
# /patches/$id/
patches_router = routers.SimpleRouter()
patches_router.register(r'patches', api.PatchViewSet)
69 70
# /patches/$id/test-restults/
patch_results_router = routers.NestedSimpleRouter(patches_router, 'patches',
71
                                                  lookup='patch')
72 73
patch_results_router.register(r'test-results', api.PatchResultViewSet,
                              base_name='patch-results')
Jeremy Kerr's avatar
Jeremy Kerr committed
74

75

76 77
admin.autodiscover()

Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
78
urlpatterns = [
79 80
    url(r'^admin/', include(admin.site.urls)),

81
    # API
82
    url(r'^api/1.0/$', api.API.as_view(), name='api-root'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
83 84 85 86 87 88 89 90 91
    url(r'^api/1.0/', include(project_router.urls)),
    url(r'^api/1.0/', include(patches_list_router.urls)),
    url(r'^api/1.0/', include(series_list_router.urls)),
    url(r'^api/1.0/', include(series_router.urls)),
    url(r'^api/1.0/', include(revisions_router.urls)),
    url(r'^api/1.0/', include(revision_results_router.urls)),
    url(r'^api/1.0/', include(patches_router.urls)),
    url(r'^api/1.0/', include(patch_results_router.urls)),
    url(r'^api/1.0/', include(event_router.urls)),
92 93
    url(r'^api/1.0/msgids/(?P<msgid>[^/]+)/$', api.msgid,
                                                name='msgid_to_patches'),
94

95
    # project views:
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
96 97 98 99
    url(r'^$', patchwork.views.base.projects,
        name='root'),
    url(r'^project/(?P<project_id>[^/]+)/list/$', patchwork.views.patch.list,
        name='patch_list'),
100
    url(r'^project/(?P<project_id>[^/]+)/patches/$',
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
101 102 103 104
        patchwork.views.patch.list,
        name='patches_list'),
    url(r'^project/(?P<project_id>[^/]+)/$', patchwork.views.project.project,
        name='project'),
Jeremy Kerr's avatar
Jeremy Kerr committed
105

106
    # series views
107
    url(r'^project/(?P<project>[^/]+)/series/$', SeriesListView.as_view(),
108
        name='series_list'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
109 110
    url(r'^series/(?P<series>\d+)/$', SeriesView.as_view(),
        name='series'),
111

Jeremy Kerr's avatar
Jeremy Kerr committed
112
    # patch views
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
113 114 115 116 117 118 119 120
    url(r'^patch/(?P<patch_id>\d+)/$', patchwork.views.patch.patch,
        name='patch'),
    url(r'^patch/(?P<patch_id>\d+)/raw/$', patchwork.views.patch.content,
        name='patch_content'),
    url(r'^patch/(?P<patch_id>\d+)/mbox/$', patchwork.views.patch.mbox,
        name='patch_mbox'),
    url(r'^patch/msgid/(?P<msgid>[^/]+)/$', patchwork.views.patch.msgid,
        name='patch_msgid'),
Jeremy Kerr's avatar
Jeremy Kerr committed
121

122 123
    # project bundles
    url(r'^project/(?P<project_id>[^/]+)/bundles/$',
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
124 125
        patchwork.views.bundle.bundles,
        name='bundle_list'),
126

Jeremy Kerr's avatar
Jeremy Kerr committed
127
    # logged-in user stuff
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
128 129 130 131
    url(r'^user/$', patchwork.views.user.profile,
        name='user'),
    url(r'^user/todo/$', patchwork.views.user.todo_lists,
        name='todo_list'),
132 133
    url(r'^user/todo/(?P<project_id>[^/]+)/$', patchwork.views.user.todo_list,
        name='todo_list'),
Jeremy Kerr's avatar
Jeremy Kerr committed
134

Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
135 136
    url(r'^user/bundles/$', patchwork.views.bundle.bundles,
        name='bundle_list'),
Jeremy Kerr's avatar
Jeremy Kerr committed
137

Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
138 139 140 141
    url(r'^user/link/$', patchwork.views.user.link,
        name='user_link'),
    url(r'^user/unlink/(?P<person_id>[^/]+)/$', patchwork.views.user.unlink,
        name='user_unlink'),
Jeremy Kerr's avatar
Jeremy Kerr committed
142

143 144
    # password change
    url(r'^user/password-change/$', auth_views.password_change,
145
        name='password_change'),
146
    url(r'^user/password-change/done/$', auth_views.password_change_done,
147
        name='password_change_done'),
148
    url(r'^user/password-reset/$', auth_views.password_reset,
149
        name='password_reset'),
150
    url(r'^user/password-reset/mail-sent/$', auth_views.password_reset_done,
151
        name='password_reset_done'),
152
    url(r'^user/password-reset/(?P<uidb64>[0-9A-Za-z_\-]+)/'
153 154 155
        r'(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        auth_views.password_reset_confirm,
        name='password_reset_confirm'),
156
    url(r'^user/password-reset/complete/$',
157 158
        auth_views.password_reset_complete,
        name='password_reset_complete'),
159 160 161 162

    # login/logout
    url(r'^user/login/$', auth_views.login,
        {'template_name': 'patchwork/login.html'},
163
        name='auth_login'),
164
    url(r'^user/logout/$', auth_views.logout,
165
        {'next_page': '/'},
166
        name='auth_logout'),
167 168

    # registration
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
169 170
    url(r'^register/', patchwork.views.user.register,
        name='register'),
171

Jeremy Kerr's avatar
Jeremy Kerr committed
172
    # public view for bundles
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
173 174 175 176
    url(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$',
     patchwork.views.bundle.bundle, name='bundle'),
    url(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/mbox/$',
     patchwork.views.bundle.mbox, name='bundle_mbox'),
Jeremy Kerr's avatar
Jeremy Kerr committed
177

Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
178 179
    url(r'^confirm/(?P<key>[0-9a-f]+)/$', patchwork.views.base.confirm,
        name='confirm'),
180

Jeremy Kerr's avatar
Jeremy Kerr committed
181
    # submitter autocomplete
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
182
    url(r'^submitter/$', patchwork.views.submitter_complete),
183
    # user autocomplete
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
184
    url(r'^complete_user/$', patchwork.views.user_complete),
185

Jeremy Kerr's avatar
Jeremy Kerr committed
186
    # email setup
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
187 188 189 190 191 192
    url(r'^mail/$', patchwork.views.mail.settings,
        name='mail_settings'),
    url(r'^mail/optout/$', patchwork.views.mail.optout,
        name='mail_optout'),
    url(r'^mail/optin/$', patchwork.views.mail.optin,
        name='mail_optin'),
Jeremy Kerr's avatar
Jeremy Kerr committed
193

194
    # help!
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
195 196 197
    url(r'^help/(?P<path>.*)$', patchwork.views.base.help,
        name='help'),
]
198

199 200 201 202 203 204
if 'debug_toolbar' in settings.INSTALLED_APPS:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]

205
if settings.ENABLE_XMLRPC:
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
206 207 208 209 210 211 212 213 214
    urlpatterns += [
                   url(r'xmlrpc/$', patchwork.views.xmlrpc.xmlrpc,
                       name='xmlrpc'),
                   url(r'^pwclient/$', patchwork.views.pwclient,
                       name='pwclient'),
                   url(r'^project/(?P<project_id>[^/]+)/pwclientrc/$',
                       patchwork.views.pwclientrc,
                       name='pwclientrc'),
                   ]
215 216 217

# redirect from old urls
if settings.COMPAT_REDIR:
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
218 219 220 221 222 223
    urlpatterns += [
                   url(r'^user/bundle/(?P<bundle_id>[^/]+)/$',
                    patchwork.views.bundle.bundle_redir),
                   url(r'^user/bundle/(?P<bundle_id>[^/]+)/mbox/$',
                   patchwork.views.bundle.mbox_redir),
                   ]