@@ -76,3 +76,16 @@ if settings.ENABLE_REST_API:
LOOKUP_FIELD = 'lookup_expr'
else:
LOOKUP_FIELD = 'lookup_type'
+
+
+# reverse
+#
+# The reverse function has been moved to django.urls in Django 1.10 and
+# backwards compatible imports will be removed in Django 2.0
+
+if django.VERSION >= (1, 10):
+ from django.urls import NoReverseMatch # noqa
+ from django.urls import reverse # noqa
+else:
+ from django.core.urlresolvers import NoReverseMatch # noqa
+ from django.core.urlresolvers import reverse # noqa
@@ -20,11 +20,12 @@
from __future__ import absolute_import
from django.conf import settings
-from django.core.urlresolvers import reverse, NoReverseMatch
from django import template
from django.utils.encoding import smart_str
from django.utils.html import escape
+from patchwork.compat import reverse
+from patchwork.compat import NoReverseMatch
from patchwork.filters import filterclasses
@@ -19,11 +19,11 @@
from __future__ import absolute_import
-from django.core.urlresolvers import reverse
from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
+from patchwork.compat import reverse
from patchwork.filters import SubmitterFilter
@@ -17,9 +17,10 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
+
class AboutViewTest(TestCase):
@@ -23,13 +23,13 @@ import datetime
import unittest
from django.conf import settings
-from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.http import urlencode
from django.utils import six
from django.utils.six.moves import range
from django.utils.six.moves import zip
+from patchwork.compat import reverse
from patchwork.models import Bundle
from patchwork.models import BundlePatch
from patchwork.tests.utils import create_bundle
@@ -21,10 +21,10 @@ from __future__ import absolute_import
import json
-from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.six.moves import range
+from patchwork.compat import reverse
from patchwork.tests.utils import create_person
@@ -17,9 +17,9 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.models import EmailConfirmation
from patchwork.tests.utils import create_user
@@ -19,9 +19,9 @@
from __future__ import absolute_import
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.tests.utils import create_comment
from patchwork.tests.utils import create_cover
from patchwork.tests.utils import create_patch
@@ -16,9 +16,9 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.tests.utils import create_person
from patchwork.tests.utils import create_patch
from patchwork.tests.utils import read_patch
@@ -17,9 +17,9 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.tests.utils import create_project
@@ -22,10 +22,10 @@ from __future__ import absolute_import
from datetime import datetime as dt
import re
-from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.six.moves import zip
+from patchwork.compat import reverse
from patchwork.models import Patch
from patchwork.tests.utils import create_patch
from patchwork.tests.utils import create_person
@@ -20,9 +20,9 @@
import re
from django.core import mail
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.models import EmailOptout
from patchwork.models import EmailConfirmation
from patchwork.tests.utils import create_person
@@ -24,9 +24,9 @@ import dateutil.parser
import dateutil.tz
import email
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.tests.utils import create_comment
from patchwork.tests.utils import create_patch
from patchwork.tests.utils import create_project
@@ -17,9 +17,9 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.tests.utils import create_patches
from patchwork.tests.utils import create_project
from patchwork.tests.utils import create_user
@@ -17,9 +17,9 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.tests import utils
@@ -19,10 +19,10 @@
from django.contrib.auth.models import User
from django.core import mail
-from django.core.urlresolvers import reverse
from django.test.client import Client
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.models import EmailConfirmation, Person
from patchwork.tests.utils import create_user
@@ -21,8 +21,8 @@ from email.utils import make_msgid
import unittest
from django.conf import settings
-from django.core.urlresolvers import reverse
+from patchwork.compat import reverse
from patchwork.models import Check
from patchwork.models import Patch
from patchwork.models import Project
@@ -17,9 +17,9 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.models import Patch
from patchwork.models import State
from patchwork.tests.utils import create_patches
@@ -19,9 +19,9 @@
from django.contrib.auth.models import User
from django.core import mail
-from django.core.urlresolvers import reverse
from django.test import TestCase
+from patchwork.compat import reverse
from patchwork.models import EmailConfirmation
from patchwork.models import Person
from patchwork.models import UserProfile
@@ -17,8 +17,7 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core.urlresolvers import reverse
-
+from patchwork.compat import reverse
from patchwork.tests.browser import SeleniumTestCase
from patchwork.tests.utils import create_user
@@ -20,10 +20,10 @@
import unittest
from django.conf import settings
-from django.core.urlresolvers import reverse
from django.test import LiveServerTestCase
from django.utils.six.moves import xmlrpc_client
+from patchwork.compat import reverse
from patchwork.tests import utils
@@ -19,10 +19,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.conf import settings
-from django.core.urlresolvers import reverse
from django.http import HttpResponsePermanentRedirect
from django.shortcuts import render
+from patchwork.compat import reverse
+
def about(request):
context = {
@@ -19,13 +19,13 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required
-from django.core import urlresolvers
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.http import HttpResponseNotFound
from django.shortcuts import get_object_or_404
from django.shortcuts import render
+from patchwork.compat import reverse
from patchwork.filters import DelegateFilter
from patchwork.forms import BundleForm
from patchwork.forms import DeleteBundleForm
@@ -89,9 +89,7 @@ def bundle_detail(request, username, bundlename):
action = request.POST.get('action', '').lower()
if action == 'delete':
bundle.delete()
- return HttpResponseRedirect(
- urlresolvers.reverse('user-profile')
- )
+ return HttpResponseRedirect(reverse('user-profile'))
elif action == 'update':
form = BundleForm(request.POST, instance=bundle)
if form.is_valid():
@@ -163,8 +161,8 @@ def bundle_detail_redir(request, bundle_id):
@login_required
def bundle_mbox_redir(request, bundle_id):
bundle = get_object_or_404(Bundle, id=bundle_id, owner=request.user)
- return HttpResponseRedirect(urlresolvers.reverse(
- 'bundle-mbox', kwargs={
- 'username': request.user.username,
- 'bundlename': bundle.name,
- }))
+ return HttpResponseRedirect(
+ reverse('bundle-mbox', kwargs={
+ 'username': request.user.username,
+ 'bundlename': bundle.name,
+ }))
@@ -17,10 +17,10 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core import urlresolvers
from django import http
from django import shortcuts
+from patchwork.compat import reverse
from patchwork import models
@@ -35,5 +35,4 @@ def comment(request, comment_id):
key = 'cover_id'
return http.HttpResponseRedirect('%s#%s' % (
- urlresolvers.reverse(url, kwargs={key: submission.id}),
- comment_id))
+ reverse(url, kwargs={key: submission.id}), comment_id))
@@ -17,12 +17,12 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from django.core import urlresolvers
from django.http import Http404
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response
+from patchwork.compat import reverse
from patchwork.models import CoverLetter
from patchwork.models import Submission
@@ -35,9 +35,7 @@ def cover_detail(request, cover_id):
submissions = Submission.objects.filter(id=cover_id)
if submissions:
return HttpResponseRedirect(
- urlresolvers.reverse(
- 'patch-detail',
- kwargs={'patch_id': cover_id}))
+ reverse('patch-detail', kwargs={'patch_id': cover_id}))
raise exc
context = {
@@ -21,11 +21,11 @@ import smtplib
from django.conf import settings as conf_settings
from django.core.mail import send_mail
-from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render
from patchwork.compat import render_to_string
+from patchwork.compat import reverse
from patchwork.forms import EmailForm
from patchwork.models import EmailConfirmation
from patchwork.models import EmailOptout
@@ -18,7 +18,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.contrib import messages
-from django.core import urlresolvers
from django.http import Http404
from django.http import HttpResponse
from django.http import HttpResponseForbidden
@@ -26,6 +25,7 @@ from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render
+from patchwork.compat import reverse
from patchwork.forms import CreateBundleForm
from patchwork.forms import PatchForm
from patchwork.models import Bundle
@@ -52,9 +52,7 @@ def patch_detail(request, patch_id):
submissions = Submission.objects.filter(id=patch_id)
if submissions:
return HttpResponseRedirect(
- urlresolvers.reverse(
- 'cover-detail',
- kwargs={'cover_id': patch_id}))
+ reverse('cover-detail', kwargs={'cover_id': patch_id}))
raise exc
editable = patch.is_editable(request.user)
@@ -19,11 +19,11 @@
from django.conf import settings
from django.contrib.auth.models import User
-from django.core import urlresolvers
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render
+from patchwork.compat import reverse
from patchwork.models import Patch
from patchwork.models import Project
@@ -33,8 +33,8 @@ def project_list(request):
if projects.count() == 1:
return HttpResponseRedirect(
- urlresolvers.reverse('patch-list',
- kwargs={'project_id': projects[0].linkname}))
+ reverse('patch-list',
+ kwargs={'project_id': projects[0].linkname}))
context = {
'projects': projects,
@@ -24,12 +24,12 @@ from django.contrib.auth.decorators import login_required
from django.contrib.sites.models import Site
from django.conf import settings
from django.core.mail import send_mail
-from django.core import urlresolvers
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from patchwork.compat import render_to_string
+from patchwork.compat import reverse
from patchwork.filters import DelegateFilter
from patchwork.forms import EmailForm
from patchwork.forms import RegistrationForm
@@ -188,7 +188,7 @@ def unlink(request, person_id):
person.user = None
person.save()
- return HttpResponseRedirect(urlresolvers.reverse('user-profile'))
+ return HttpResponseRedirect(reverse('user-profile'))
@login_required
@@ -204,7 +204,7 @@ def todo_lists(request):
if len(todo_lists) == 1:
return HttpResponseRedirect(
- urlresolvers.reverse(
+ reverse(
'user-todo',
kwargs={'project_id': todo_lists[0]['project'].linkname}))
@@ -30,7 +30,6 @@ except ImportError:
from xmlrpc.server import XMLRPCDocGenerator
import sys
-from django.core.urlresolvers import reverse
from django.contrib.auth import authenticate
from django.http import HttpResponse
from django.http import HttpResponseRedirect
@@ -40,6 +39,7 @@ from django.utils import six
from django.utils.six.moves import xmlrpc_client
from django.utils.six.moves.xmlrpc_server import SimpleXMLRPCDispatcher
+from patchwork.compat import reverse
from patchwork.models import Check
from patchwork.models import Patch
from patchwork.models import Person
This raises a warning in Django 1.10 and will cause an error in 2.0. Signed-off-by: Stephen Finucane <stephen@that.guru> --- patchwork/compat.py | 13 +++++++++++++ patchwork/templatetags/listurl.py | 3 ++- patchwork/templatetags/person.py | 2 +- patchwork/tests/test_about.py | 3 ++- patchwork/tests/test_bundles.py | 2 +- patchwork/tests/test_completion.py | 2 +- patchwork/tests/test_confirm.py | 2 +- patchwork/tests/test_detail.py | 2 +- patchwork/tests/test_encodings.py | 2 +- patchwork/tests/test_filters.py | 2 +- patchwork/tests/test_list.py | 2 +- patchwork/tests/test_mail_settings.py | 2 +- patchwork/tests/test_mboxviews.py | 2 +- patchwork/tests/test_paginator.py | 2 +- patchwork/tests/test_projects.py | 2 +- patchwork/tests/test_registration.py | 2 +- patchwork/tests/test_rest_api.py | 2 +- patchwork/tests/test_updates.py | 2 +- patchwork/tests/test_user.py | 2 +- patchwork/tests/test_user_browser.py | 3 +-- patchwork/tests/test_xmlrpc.py | 2 +- patchwork/views/about.py | 3 ++- patchwork/views/bundle.py | 16 +++++++--------- patchwork/views/comment.py | 5 ++--- patchwork/views/cover.py | 6 ++---- patchwork/views/mail.py | 2 +- patchwork/views/patch.py | 6 ++---- patchwork/views/project.py | 6 +++--- patchwork/views/user.py | 6 +++--- patchwork/views/xmlrpc.py | 2 +- 30 files changed, 58 insertions(+), 50 deletions(-)