urls.py 8.77 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
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
22
from django.urls import path
23
from django.contrib import admin
24
from django.contrib.auth import views as auth_views
25
from rest_framework_nested import routers
26
from patchwork.views.series import SeriesListView, SeriesView
27
import patchwork.views.api as api
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
28 29 30 31 32 33 34 35
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
36 37 38 39 40 41

# API

# /projects/$project/
project_router = routers.SimpleRouter()
project_router.register('projects', api.ProjectViewSet)
42 43 44 45
# /projects/$project/patches/
patches_list_router = routers.NestedSimpleRouter(project_router, 'projects',
                                                 lookup='project')
patches_list_router.register(r'patches', api.PatchListViewSet)
46 47 48 49
# /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
50 51 52 53
# /projects/$project/events/
event_router = routers.NestedSimpleRouter(project_router, 'projects',
                                          lookup='project')
event_router.register(r'events', api.EventLogViewSet)
54 55 56 57 58
# /series/$id/
series_router = routers.SimpleRouter()
series_router.register(r'series', api.SeriesViewSet)
# /series/$id/revisions/$rev
revisions_router = routers.NestedSimpleRouter(series_router, 'series',
59
                                              lookup='series')
60
revisions_router.register(r'revisions', api.RevisionViewSet)
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,
66
                                 basename='revision-results')
67 68 69
# /patches/$id/
patches_router = routers.SimpleRouter()
patches_router.register(r'patches', api.PatchViewSet)
70 71
# /patches/$id/test-restults/
patch_results_router = routers.NestedSimpleRouter(patches_router, 'patches',
72
                                                  lookup='patch')
73
patch_results_router.register(r'test-results', api.PatchResultViewSet,
74
                              basename='patch-results')
Jeremy Kerr's avatar
Jeremy Kerr committed
75

Stephen Finucane's avatar
Stephen Finucane committed
76

77 78
admin.autodiscover()

Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
79
urlpatterns = [
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
80
    path('admin/', admin.site.urls),
81

82
    # API
83
    url(r'^api/1.0/$', api.API.as_view(), name='api-root'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
84 85 86 87 88 89 90 91 92
    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)),
93 94
    url(r'^api/1.0/msgids/(?P<msgid>[^/]+)/$', api.MsgidResultsView.as_view(),
                                               name='msgid_to_series'),
95

Damien Lespiau's avatar
Damien Lespiau committed
96
    # project views:
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
97 98 99 100
    url(r'^$', patchwork.views.base.projects,
        name='root'),
    url(r'^project/(?P<project_id>[^/]+)/list/$', patchwork.views.patch.list,
        name='patch_list'),
101
    url(r'^project/(?P<project_id>[^/]+)/patches/$',
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
102 103 104 105
        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
106

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

Jeremy Kerr's avatar
Jeremy Kerr committed
113
    # patch views
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
114 115 116 117 118 119 120 121
    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
122

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

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

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

Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
139 140 141 142
    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
143

144
    # password change
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
145 146
    path('user/password-change/',
        auth_views.PasswordChangeView.as_view(),
147
        name='password_change'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
148 149
    path('user/password-change/done/',
        auth_views.PasswordChangeDoneView.as_view(),
150
        name='password_change_done'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
151 152
    path('user/password-reset/',
        auth_views.PasswordResetView.as_view(),
153
        name='password_reset'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
154 155
    path('user/password-reset/mail-sent/',
        auth_views.PasswordResetDoneView.as_view(),
156
        name='password_reset_done'),
aldot's avatar
aldot committed
157
    url(r'^user/password-reset/(?P<uidb64>[0-9A-Za-z_\-]+)/'
158
        r'(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
159
        auth_views.PasswordResetConfirmView.as_view(),
160
        name='password_reset_confirm'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
161 162
    path('user/password-reset/complete/',
        auth_views.PasswordResetCompleteView.as_view(),
163
        name='password_reset_complete'),
164 165

    # login/logout
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
166 167 168
    path('user/login/', auth_views.LoginView.as_view(
            template_name='patchwork/login.html'
        ),
169
        name='auth_login'),
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
170
    path('user/logout/', auth_views.LoginView.as_view(),
171
        {'next_page': '/'},
172
        name='auth_logout'),
173 174

    # registration
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
175 176
    url(r'^register/', patchwork.views.user.register,
        name='register'),
177

Jeremy Kerr's avatar
Jeremy Kerr committed
178
    # public view for bundles
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
179 180 181 182
    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
183

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

Jeremy Kerr's avatar
Jeremy Kerr committed
187
    # submitter autocomplete
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
188
    url(r'^submitter/$', patchwork.views.submitter_complete),
189
    # user autocomplete
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
190
    url(r'^complete_user/$', patchwork.views.user_complete),
191

Jeremy Kerr's avatar
Jeremy Kerr committed
192
    # email setup
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
193 194 195 196 197 198
    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
199

200
    # help!
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
201 202 203
    url(r'^help/(?P<path>.*)$', patchwork.views.base.help,
        name='help'),
]
204

205 206 207
if 'debug_toolbar' in settings.INSTALLED_APPS:
    import debug_toolbar
    urlpatterns += [
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
208
        path('^__debug__/', include(debug_toolbar.urls)),
209 210
    ]

211
if settings.ENABLE_XMLRPC:
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
212 213 214 215 216 217 218 219 220
    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'),
                   ]
221 222 223

# redirect from old urls
if settings.COMPAT_REDIR:
Arkadiusz Hiler's avatar
Arkadiusz Hiler committed
224 225 226 227 228 229
    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),
                   ]