From: Stephen Finucane Date: Tue, 8 Dec 2015 15:08:11 +0000 (+0000) Subject: urls: Add url names X-Git-Tag: v1.1.0~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=68686d1774ea74e71f16ae098d28a321a2f930a3;p=thirdparty%2Fpatchwork.git urls: Add url names Reverse by name is an alternative to reverse by Python path. The names must be added as a prerequisite for removing reverse by Python path, per Django documentation. https://docs.djangoproject.com/en/1.9/ref/urlresolvers/#django.core.urlresolvers.reverse Signed-off-by: Stephen Finucane --- diff --git a/patchwork/urls.py b/patchwork/urls.py index 5be286a8..57b1a108 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -29,24 +29,35 @@ urlpatterns = patterns( '', url(r'^admin/', include(admin.site.urls)), - (r'^$', 'patchwork.views.project.list'), - (r'^project/(?P[^/]+)/list/$', 'patchwork.views.patch.list'), - (r'^project/(?P[^/]+)/$', 'patchwork.views.project.project'), + url(r'^$', 'patchwork.views.project.list', name='project-list'), + url(r'^project/(?P[^/]+)/list/$', 'patchwork.views.patch.list', + name='patch-list'), + url(r'^project/(?P[^/]+)/$', 'patchwork.views.project.project', + name='project-detail'), # patch views - (r'^patch/(?P\d+)/$', 'patchwork.views.patch.patch'), - (r'^patch/(?P\d+)/raw/$', 'patchwork.views.patch.content'), - (r'^patch/(?P\d+)/mbox/$', 'patchwork.views.patch.mbox'), + url(r'^patch/(?P\d+)/$', 'patchwork.views.patch.patch', + name='patch-detail'), + url(r'^patch/(?P\d+)/raw/$', 'patchwork.views.patch.content', + name='patch-raw'), + url(r'^patch/(?P\d+)/mbox/$', 'patchwork.views.patch.mbox', + name='patch-mbox'), # logged-in user stuff - (r'^user/$', 'patchwork.views.user.profile'), - (r'^user/todo/$', 'patchwork.views.user.todo_lists'), - (r'^user/todo/(?P[^/]+)/$', 'patchwork.views.user.todo_list'), + url(r'^user/$', 'patchwork.views.user.profile', name='user-profile'), + url(r'^user/todo/$', 'patchwork.views.user.todo_lists', + name='user-todos'), + url(r'^user/todo/(?P[^/]+)/$', + 'patchwork.views.user.todo_list', + name='user-todo'), - (r'^user/bundles/$', 'patchwork.views.bundle.bundles'), + url(r'^user/bundles/$', 'patchwork.views.bundle.bundles', + name='bundle-list'), - (r'^user/link/$', 'patchwork.views.user.link'), - (r'^user/unlink/(?P[^/]+)/$', 'patchwork.views.user.unlink'), + url(r'^user/link/$', 'patchwork.views.user.link', + name='user-link'), + url(r'^user/unlink/(?P[^/]+)/$', 'patchwork.views.user.unlink', + name='user-unlink'), # password change url(r'^user/password-change/$', auth_views.password_change, @@ -74,43 +85,51 @@ urlpatterns = patterns( name='auth_logout'), # registration - (r'^register/', 'patchwork.views.user.register'), + url(r'^register/', 'patchwork.views.user.register', name='user-register'), # public view for bundles - (r'^bundle/(?P[^/]*)/(?P[^/]*)/$', - 'patchwork.views.bundle.bundle'), - (r'^bundle/(?P[^/]*)/(?P[^/]*)/mbox/$', - 'patchwork.views.bundle.mbox'), + url(r'^bundle/(?P[^/]*)/(?P[^/]*)/$', + 'patchwork.views.bundle.bundle', + name='bundle-detail'), + url(r'^bundle/(?P[^/]*)/(?P[^/]*)/mbox/$', + 'patchwork.views.bundle.mbox', + name='bundle-mbox'), - (r'^confirm/(?P[0-9a-f]+)/$', 'patchwork.views.confirm'), + url(r'^confirm/(?P[0-9a-f]+)/$', 'patchwork.views.confirm', + name='confirm'), # submitter autocomplete - (r'^submitter/$', 'patchwork.views.api.submitters'), + url(r'^submitter/$', 'patchwork.views.api.submitters', + name='api-submitters'), # email setup - (r'^mail/$', 'patchwork.views.mail.settings'), - (r'^mail/optout/$', 'patchwork.views.mail.optout'), - (r'^mail/optin/$', 'patchwork.views.mail.optin'), + 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'), # help! - (r'^help/(?P.*)$', 'patchwork.views.help.help'), + url(r'^help/(?P.*)$', 'patchwork.views.help.help', name='help'), ) if settings.ENABLE_XMLRPC: urlpatterns += patterns( '', - (r'xmlrpc/$', 'patchwork.views.xmlrpc.xmlrpc'), - (r'^pwclient/$', 'patchwork.views.pwclient.pwclient'), - (r'^project/(?P[^/]+)/pwclientrc/$', - 'patchwork.views.pwclient.pwclientrc'), + url(r'xmlrpc/$', 'patchwork.views.xmlrpc.xmlrpc', name='xmlrpc'), + url(r'^pwclient/$', 'patchwork.views.pwclient.pwclient', + name='pwclient'), + url(r'^project/(?P[^/]+)/pwclientrc/$', + 'patchwork.views.pwclient.pwclientrc', + name='pwclientrc'), ) # redirect from old urls if settings.COMPAT_REDIR: urlpatterns += patterns( '', - (r'^user/bundle/(?P[^/]+)/$', - 'patchwork.views.bundle.bundle_redir'), - (r'^user/bundle/(?P[^/]+)/mbox/$', - 'patchwork.views.bundle.mbox_redir'), + url(r'^user/bundle/(?P[^/]+)/$', + 'patchwork.views.bundle.bundle_redir', + name='bundle-redir'), + url(r'^user/bundle/(?P[^/]+)/mbox/$', + 'patchwork.views.bundle.mbox_redir', + name='bundle-mbox-redir'), )