From patchwork Thu Nov 2 10:28:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 833284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ySM3W3rn9z9sBd for ; Thu, 2 Nov 2017 21:37:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="uBWgqleM"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3ySM3Q6mzJzDr5T for ; Thu, 2 Nov 2017 21:37:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="uBWgqleM"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.214.27; helo=butterfly.maple.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="uBWgqleM"; dkim-atps=neutral Received: from butterfly.maple.relay.mailchannels.net (butterfly.maple.relay.mailchannels.net [23.83.214.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3ySM2B0494zDr5T for ; Thu, 2 Nov 2017 21:36:01 +1100 (AEDT) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C1B745C97C4 for ; Thu, 2 Nov 2017 10:29:01 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.143.180]) (Authenticated sender: mxroute) by relay.mailchannels.net (Postfix) with ESMTPA id 56A5D5C98C1 for ; Thu, 2 Nov 2017 10:29:01 +0000 (UTC) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.20.113.32]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.9.14); Thu, 02 Nov 2017 10:29:01 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: mxroute|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: mxroute X-Harbor-Chemical: 116df0a03daa161d_1509618541601_765228321 X-MC-Loop-Signature: 1509618541601:108230852 X-MC-Ingress-Time: 1509618541601 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kdnUwO6ekcSdvAGxZZqza07n/LSAHPuzz4Qx5h5A5XI=; b=uBWgqleMX+OB0iFFmtLvhXMRkI oyqctSZ41mKTkBe6X5XiwOAafSETp4n+tWsr2J9Kq7oS9sRi5SqXC481zKSs8ENSHn783tzInNiIF uUWyhbGsfztYl8kne3wCN/G9/Pbrji3bN9Iv7GUVntijeeNe8k/VZ48wGl4N1ZxEYlvCNfj/gs0Ii aSFL0ujNOVOQfUqBIWHiw7P+eWU0C+TNpjtKDcLvO6XvLvsx6Om2lHGeqHlzPXHzBHswASff14zDl 3I6IXLezctcrsrYoR7qY9lgs43IkhAD2CEDLltoDJhOeGhhYXU4si/oj/J2BIPNcc+dOV8P0m+yBk WJybdUGA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v2 2/9] urls: Use new login/password change CBVs Date: Thu, 2 Nov 2017 10:28:37 +0000 Message-Id: <20171102102844.18931-3-stephen@that.guru> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171102102844.18931-1-stephen@that.guru> References: <20171102102844.18931-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" The function based views are deprecated in Django 1.11 [1], so support the newer class based views. [1] https://docs.djangoproject.com/en/dev/releases/1.11/#id2 Signed-off-by: Stephen Finucane --- patchwork/urls.py | 94 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/patchwork/urls.py b/patchwork/urls.py index 285d5659..b33b01c4 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -17,11 +17,13 @@ # along with Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import django 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 patchwork.compat import reverse from patchwork.views import about as about_views from patchwork.views import api as api_views from patchwork.views import bundle as bundle_views @@ -85,32 +87,75 @@ urlpatterns = [ name='user-link'), url(r'^user/unlink/(?P[^/]+)/$', user_views.unlink, name='user-unlink'), +] - # password change - url(r'^user/password-change/$', auth_views.password_change, - name='password_change'), - url(r'^user/password-change/done/$', auth_views.password_change_done, - name='password_change_done'), - url(r'^user/password-reset/$', auth_views.password_reset, - name='password_reset'), - url(r'^user/password-reset/mail-sent/$', auth_views.password_reset_done, - name='password_reset_done'), - url(r'^user/password-reset/(?P[0-9A-Za-z_\-]+)/' - r'(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', - auth_views.password_reset_confirm, - name='password_reset_confirm'), - url(r'^user/password-reset/complete/$', - auth_views.password_reset_complete, - name='password_reset_complete'), - - # login/logout - url(r'^user/login/$', auth_views.login, - {'template_name': 'patchwork/login.html'}, - name='auth_login'), - url(r'^user/logout/$', auth_views.logout, - {'next_page': '/'}, - name='auth_logout'), +# password change +if django.VERSION > (1, 11): + urlpatterns += [ + 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[0-9A-Za-z_\-]+)/' + r'(?P[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'), + ] +else: + urlpatterns += [ + url(r'^user/password-change/$', + auth_views.password_change, + name='password_change'), + url(r'^user/password-change/done/$', + auth_views.password_change_done, + name='password_change_done'), + url(r'^user/password-reset/$', + auth_views.password_reset, + name='password_reset'), + url(r'^user/password-reset/mail-sent/$', + auth_views.password_reset_done, + name='password_reset_done'), + url(r'^user/password-reset/(?P[0-9A-Za-z_\-]+)/' + r'(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', + auth_views.password_reset_confirm, + name='password_reset_confirm'), + url(r'^user/password-reset/complete/$', + auth_views.password_reset_complete, + name='password_reset_complete'), + ] +# login/logout +if django.VERSION >= (1, 11): + urlpatterns += [ + 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('project-list')), + name='auth_logout'), + ] +else: + urlpatterns += [ + url(r'^user/login/$', auth_views.login, + {'template_name': 'patchwork/login.html'}, + name='auth_login'), + url(r'^user/logout/$', auth_views.logout, + {'next_page': reverse('project-list')}, + name='auth_logout'), + ] + +urlpatterns += [ # registration url(r'^register/', user_views.register, name='user-register'), @@ -144,6 +189,7 @@ urlpatterns = [ if 'debug_toolbar' in settings.INSTALLED_APPS: import debug_toolbar + urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), ]