summaryrefslogtreecommitdiff
path: root/patchwork/urls.py
blob: 7d888d4a3dc0152003a7ce4c2c6d92e164e03641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# Patchwork - automated patch tracking system
# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later

from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import reverse_lazy

from patchwork.views import about as about_views
from patchwork.views import api as api_views
from patchwork.views import bundle as bundle_views
from patchwork.views import comment as comment_views
from patchwork.views import cover as cover_views
from patchwork.views import mail as mail_views
from patchwork.views import notification as notification_views
from patchwork.views import patch as patch_views
from patchwork.views import project as project_views
from patchwork.views import pwclient as pwclient_views
from patchwork.views import series as series_views
from patchwork.views import user as user_views
from patchwork.views import xmlrpc as xmlrpc_views


admin.autodiscover()

urlpatterns = [
    url(r'^admin/', admin.site.urls),

    url(r'^$', project_views.project_list, name='project-list'),
    url(r'^project/(?P<project_id>[^/]+)/list/$', patch_views.patch_list,
        name='patch-list'),
    url(r'^project/(?P<project_id>[^/]+)/bundles/$', bundle_views.bundle_list,
        name='bundle-list'),
    url(r'^project/(?P<project_id>[^/]+)/$', project_views.project_detail,
        name='project-detail'),

    # patch views
    # NOTE(dja): Per the RFC, msgids can contain slashes. There doesn't seem
    # to be an easy way to tell Django to urlencode the slash when generating
    # URLs, so instead we must use a permissive regex (.+ rather than [^/]+).
    # This also means we need to put the raw and mbox URLs first, otherwise the
    # patch-detail regex will just greedily grab those parts into a massive and
    # wrong msgid.
    #
    # This does mean that message-ids that end in '/raw/' or '/mbox/' will not
    # work, but it is RECOMMENDED by the RFC that the right hand side of the @
    # contains a domain, so I think breaking on messages that have "domains"
    # ending in /raw/ or /mbox/ is good enough.
    url(r'^project/(?P<project_id>[^/]+)/patch/(?P<msgid>.+)/raw/$',
        patch_views.patch_raw, name='patch-raw'),
    url(r'^project/(?P<project_id>[^/]+)/patch/(?P<msgid>.+)/mbox/$',
        patch_views.patch_mbox, name='patch-mbox'),
    url(r'^project/(?P<project_id>[^/]+)/patch/(?P<msgid>.+)/$',
        patch_views.patch_detail, name='patch-detail'),
    # ... old-style /patch/N/* urls
    url(r'^patch/(?P<patch_id>\d+)/raw/$', patch_views.patch_raw_by_id,
        name='patch-raw-redirect'),
    url(r'^patch/(?P<patch_id>\d+)/mbox/$', patch_views.patch_mbox_by_id,
        name='patch-mbox-redirect'),
    url(r'^patch/(?P<patch_id>\d+)/$', patch_views.patch_by_id,
        name='patch-id-redirect'),

    # cover views
    url(r'^project/(?P<project_id>[^/]+)/cover/(?P<msgid>.+)/mbox/$',
        cover_views.cover_mbox, name='cover-mbox'),
    url(r'^project/(?P<project_id>[^/]+)/cover/(?P<msgid>.+)/$',
        cover_views.cover_detail, name='cover-detail'),
    # ... old-style /cover/N/* urls
    url(r'^cover/(?P<cover_id>\d+)/mbox/$', cover_views.cover_mbox_by_id,
        name='cover-mbox-redirect'),
    url(r'^cover/(?P<cover_id>\d+)/$', cover_views.cover_by_id,
        name='cover-id-redirect'),

    # comment views
    url(r'^comment/(?P<comment_id>\d+)/$', comment_views.comment,
        name='comment-redirect'),

    # series views
    url(r'^series/(?P<series_id>\d+)/mbox/$', series_views.series_mbox,
        name='series-mbox'),

    # logged-in user stuff
    url(r'^user/$', user_views.profile, name='user-profile'),
    url(r'^user/todo/$', user_views.todo_lists,
        name='user-todos'),
    url(r'^user/todo/(?P<project_id>[^/]+)/$', user_views.todo_list,
        name='user-todo'),
    url(r'^user/bundles/$', bundle_views.bundle_list,
        name='user-bundles'),

    url(r'^user/link/$', user_views.link,
        name='user-link'),
    url(r'^user/unlink/(?P<person_id>[^/]+)/$', user_views.unlink,
        name='user-unlink'),

    # password change
    url(r'^user/password-change/$',
        auth_views.PasswordChangeView.as_view(),
        name='password_change'),
    url(r'^user/password-change/done/$',
        auth_views.PasswordChangeDoneView.as_view(),
        name='password_change_done'),
    url(r'^user/password-reset/$',
        auth_views.PasswordResetView.as_view(),
        name='password_reset'),
    url(r'^user/password-reset/mail-sent/$',
        auth_views.PasswordResetDoneView.as_view(),
        name='password_reset_done'),
    url(r'^user/password-reset/(?P<uidb64>[0-9A-Za-z_\-]+)/'
        r'(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        auth_views.PasswordResetConfirmView.as_view(),
        name='password_reset_confirm'),
    url(r'^user/password-reset/complete/$',
        auth_views.PasswordResetCompleteView.as_view(),
        name='password_reset_complete'),

    # login/logout
    url(r'^user/login/$', auth_views.LoginView.as_view(
        template_name='patchwork/login.html'),
        name='auth_login'),
    url(r'^user/logout/$', auth_views.LogoutView.as_view(
        next_page=reverse_lazy('project-list')),
        name='auth_logout'),

    # registration
    url(r'^register/', user_views.register, name='user-register'),

    # public view for bundles
    url(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$',
        bundle_views.bundle_detail,
        name='bundle-detail'),
    url(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/mbox/$',
        bundle_views.bundle_mbox,
        name='bundle-mbox'),

    url(r'^confirm/(?P<key>[0-9a-f]+)/$', notification_views.confirm,
        name='confirm'),

    # submitter autocomplete
    url(r'^submitter/$', api_views.submitters, name='api-submitters'),
    url(r'^delegate/$', api_views.delegates, name='api-delegates'),

    # email setup
    url(r'^mail/$', mail_views.settings, name='mail-settings'),
    url(r'^mail/optout/$', mail_views.optout, name='mail-optout'),
    url(r'^mail/optin/$', mail_views.optin, name='mail-optin'),

    # about
    url(r'^about/$', about_views.about, name='about'),

    # legacy redirects
    url(r'^help/$', about_views.redirect, name='help'),
    url(r'^help/about/$', about_views.redirect, name='help-about'),
]

if 'debug_toolbar' in settings.INSTALLED_APPS:
    import debug_toolbar  # noqa

    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]

if settings.ENABLE_XMLRPC:
    urlpatterns += [
        url(r'xmlrpc/$', xmlrpc_views.xmlrpc, name='xmlrpc'),
        url(r'^project/(?P<project_id>[^/]+)/pwclientrc/$',
            pwclient_views.pwclientrc,
            name='pwclientrc'),
        # legacy redirect
        url(r'^help/pwclient/$', about_views.redirect, name='help-pwclient'),
    ]

if settings.ENABLE_REST_API:
    if 'rest_framework' not in settings.INSTALLED_APPS:
        raise RuntimeError(
            'djangorestframework must be installed to enable the REST API.')

    from patchwork.api import bundle as api_bundle_views  # noqa
    from patchwork.api import check as api_check_views  # noqa
    from patchwork.api import comment as api_comment_views  # noqa
    from patchwork.api import cover as api_cover_views  # noqa
    from patchwork.api import event as api_event_views  # noqa
    from patchwork.api import index as api_index_views  # noqa
    from patchwork.api import patch as api_patch_views  # noqa
    from patchwork.api import person as api_person_views  # noqa
    from patchwork.api import project as api_project_views  # noqa
    from patchwork.api import series as api_series_views  # noqa
    from patchwork.api import user as api_user_views  # noqa

    api_patterns = [
        url(r'^$',
            api_index_views.IndexView.as_view(),
            name='api-index'),
        url(r'^users/$',
            api_user_views.UserList.as_view(),
            name='api-user-list'),
        url(r'^users/(?P<pk>[^/]+)/$',
            api_user_views.UserDetail.as_view(),
            name='api-user-detail'),
        url(r'^people/$',
            api_person_views.PersonList.as_view(),
            name='api-person-list'),
        url(r'^people/(?P<pk>[^/]+)/$',
            api_person_views.PersonDetail.as_view(),
            name='api-person-detail'),
        url(r'^covers/$',
            api_cover_views.CoverList.as_view(),
            name='api-cover-list'),
        url(r'^covers/(?P<pk>[^/]+)/$',
            api_cover_views.CoverDetail.as_view(),
            name='api-cover-detail'),
        url(r'^patches/$',
            api_patch_views.PatchList.as_view(),
            name='api-patch-list'),
        url(r'^patches/(?P<pk>[^/]+)/$',
            api_patch_views.PatchDetail.as_view(),
            name='api-patch-detail'),
        url(r'^patches/(?P<patch_id>[^/]+)/checks/$',
            api_check_views.CheckListCreate.as_view(),
            name='api-check-list'),
        url(r'^patches/(?P<patch_id>[^/]+)/checks/(?P<check_id>[^/]+)/$',
            api_check_views.CheckDetail.as_view(),
            name='api-check-detail'),
        url(r'^series/$',
            api_series_views.SeriesList.as_view(),
            name='api-series-list'),
        url(r'^series/(?P<pk>[^/]+)/$',
            api_series_views.SeriesDetail.as_view(),
            name='api-series-detail'),
        url(r'^bundles/$',
            api_bundle_views.BundleList.as_view(),
            name='api-bundle-list'),
        url(r'^bundles/(?P<pk>[^/]+)/$',
            api_bundle_views.BundleDetail.as_view(),
            name='api-bundle-detail'),
        url(r'^projects/$',
            api_project_views.ProjectList.as_view(),
            name='api-project-list'),
        url(r'^projects/(?P<pk>[^/]+)/$',
            api_project_views.ProjectDetail.as_view(),
            name='api-project-detail'),
        url(r'^events/$',
            api_event_views.EventList.as_view(),
            name='api-event-list'),
    ]

    api_1_1_patterns = [
        url(r'^patches/(?P<pk>[^/]+)/comments/$',
            api_comment_views.PatchCommentList.as_view(),
            name='api-patch-comment-list'),
        url(r'^covers/(?P<pk>[^/]+)/comments/$',
            api_comment_views.CoverCommentList.as_view(),
            name='api-cover-comment-list'),
    ]

    urlpatterns += [
        url(r'^api/(?:(?P<version>(1.0|1.1|1.2))/)?', include(api_patterns)),
        url(r'^api/(?:(?P<version>(1.1|1.2))/)?', include(api_1_1_patterns)),

        # token change
        url(r'^user/generate-token/$', user_views.generate_token,
            name='generate_token'),
    ]


# redirect from old urls
if settings.COMPAT_REDIR:
    urlpatterns += [
        url(r'^user/bundle/(?P<bundle_id>[^/]+)/$',
            bundle_views.bundle_detail_redir,
            name='bundle-redir'),
        url(r'^user/bundle/(?P<bundle_id>[^/]+)/mbox/$',
            bundle_views.bundle_mbox_redir,
            name='bundle-mbox-redir'),
    ]