Deleting code is fun. We no longer need to carry these so don't.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
from patchwork.api.embedded import PatchSerializer
from patchwork.api.embedded import ProjectSerializer
from patchwork.api.embedded import UserSerializer
-from patchwork.compat import is_authenticated
from patchwork.models import Bundle
serializer_class = BundleSerializer
def get_queryset(self):
- if is_authenticated(self.request.user):
+ if self.request.user.is_authenticated:
bundle_filter = Q(owner=self.request.user) | Q(public=True)
else:
bundle_filter = Q(public=True)
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""Compatibility wrappers for various Django versions."""
+"""Compatibility wrappers for various library versions."""
-import django
from django.conf import settings
-# DjangoFilterBackend
-#
-# The DjangoFilterBackend was provided in Django REST Framework from 3.0 to
-# 3.4, was marked as pending deprecation in 3.5, was deprecated in 3.6 and will
-# be removed in 3.7. However, the equivalent DjangoFilterBackend found in
-# django-filter is only available since 1.0 of that package.
-#
-# http://www.django-rest-framework.org/topics/3.6-announcement/
-
-if settings.ENABLE_REST_API:
- import rest_framework # noqa
-
- if rest_framework.VERSION >= '3.5':
- from django_filters.rest_framework import DjangoFilterBackend # noqa
- else:
- from rest_framework.filters import DjangoFilterBackend # noqa
-
-
# NAME_FIELD
#
# The django-filter library renamed 'Filter.name' to 'Filter.field_name' in
NAME_FIELD = 'field_name'
else:
NAME_FIELD = 'name'
-
-
-# reverse, reverse_lazy
-#
-# The reverse and reverse_lazy functions have 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
- from django.urls import reverse_lazy # noqa
-else:
- from django.core.urlresolvers import NoReverseMatch # noqa
- from django.core.urlresolvers import reverse # noqa
- from django.core.urlresolvers import reverse_lazy # noqa
-
-
-# is_authenticated
-#
-# models.User.is_authenticated is now an attribute in Django 1.10 instead of a
-# function
-#
-# https://docs.djangoproject.com/en/dev/releases/1.10/
-
-def is_authenticated(user):
- if django.VERSION >= (1, 10):
- return user.is_authenticated
- else:
- return user.is_authenticated()
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
+from django.urls import reverse
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
-from patchwork.compat import is_authenticated
-from patchwork.compat import reverse
from patchwork.fields import HashField
from patchwork.hasher import hash_diff
use_tags = models.BooleanField(default=True)
def is_editable(self, user):
- if not is_authenticated(user):
+ if not user.is_authenticated:
return False
return self in user.profile.maintainer_projects.all()
self.refresh_tag_counts()
def is_editable(self, user):
- if not is_authenticated(user):
+ if not user.is_authenticated:
return False
if user in [self.submitter.user, self.delegate]:
from django.conf import settings
from django.core import paginator
-from patchwork.compat import is_authenticated
-
DEFAULT_ITEMS_PER_PAGE = 100
LONG_PAGE_THRESHOLD = 30
items_per_page = settings.DEFAULT_ITEMS_PER_PAGE
- if is_authenticated(request.user):
+ if request.user.is_authenticated:
items_per_page = request.user.profile.items_per_page
super(Paginator, self).__init__(objects, items_per_page)
'rest_framework.versioning.URLPathVersioning',
'DEFAULT_PAGINATION_CLASS': 'patchwork.api.base.LinkHeaderPagination',
'DEFAULT_FILTER_BACKENDS': (
- 'patchwork.compat.DjangoFilterBackend',
+ 'django_filters.rest_framework.DjangoFilterBackend',
'rest_framework.filters.SearchFilter',
'rest_framework.filters.OrderingFilter',
),
from django.conf import settings
from django import template
+from django.urls import reverse
+from django.urls import NoReverseMatch
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
from __future__ import absolute_import
from django import template
+from django.urls import reverse
from django.utils.html import escape
from django.utils.safestring import mark_safe
-from patchwork.compat import reverse
from patchwork.filters import SubmitterFilter
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests.utils import create_bundle
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_project
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import Check
from patchwork.tests.utils import create_check
from patchwork.tests.utils import create_patch
import unittest
from django.conf import settings
+from django.urls import NoReverseMatch
+from django.urls import reverse
-from patchwork.compat import NoReverseMatch
-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
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests.utils import create_cover
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_person
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import Patch
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_patch
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_person
from patchwork.tests.utils import create_user
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import Project
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_project
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests.utils import create_cover
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_project
import unittest
from django.conf import settings
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests.utils import create_maintainer
from patchwork.tests.utils import create_user
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
-
-from patchwork.compat import reverse
+from django.urls import reverse
class AboutViewTest(TestCase):
from django.conf import settings
from django.test import TestCase
+from django.urls import reverse
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
import json
from django.test import TestCase
+from django.urls import reverse
from django.utils.six.moves import range
-from patchwork.compat import reverse
from patchwork.tests.utils import create_person
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import EmailConfirmation
from patchwork.tests.utils import create_user
from __future__ import absolute_import
from django.test import TestCase
+from django.urls import reverse
-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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
+from django.urls import reverse
-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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests.utils import create_project
import re
from django.test import TestCase
+from django.urls import reverse
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
from django.core import mail
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import EmailOptout
from patchwork.models import EmailConfirmation
from patchwork.tests.utils import create_person
import email
from django.test import TestCase
+from django.urls import reverse
-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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
+from django.urls import reverse
-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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.tests import utils
from django.core import mail
from django.test.client import Client
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import EmailConfirmation, Person
from patchwork.tests.utils import create_user
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import Patch
from patchwork.models import State
from patchwork.tests.utils import create_patches
from django.contrib.auth.models import User
from django.core import mail
from django.test import TestCase
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import EmailConfirmation
from patchwork.models import Person
from patchwork.models import UserProfile
from django.conf import settings
from django.test import LiveServerTestCase
+from django.urls import reverse
from django.utils.six.moves import xmlrpc_client
-from patchwork.compat import reverse
from patchwork.tests import utils
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.compat 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 django.contrib import messages
from django.shortcuts import get_object_or_404
-from patchwork.compat import is_authenticated
from patchwork.filters import Filters
from patchwork.forms import MultiplePatchForm
from patchwork.models import Bundle
user = request.user
properties_form = None
- if is_authenticated(user):
+ if user.is_authenticated:
# we only pass the post data to the MultiplePatchForm if that was
# the actual form submitted
data_tmp = None
from django.conf import settings
from django.http import HttpResponsePermanentRedirect
from django.shortcuts import render
-
-from patchwork.compat import reverse
+from django.urls import reverse
def about(request):
from django.http import HttpResponseNotFound
from django.shortcuts import get_object_or_404
from django.shortcuts import render
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.filters import DelegateFilter
from patchwork.forms import BundleForm
from patchwork.forms import DeleteBundleForm
from django import http
from django import shortcuts
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork import models
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import CoverLetter
from patchwork.models import Submission
from patchwork.views.utils import cover_to_mbox
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.template.loader import render_to_string
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.forms import EmailForm
from patchwork.models import EmailConfirmation
from patchwork.models import EmailOptout
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render
+from django.urls import reverse
-from patchwork.compat import reverse
-from patchwork.compat import is_authenticated
from patchwork.forms import CreateBundleForm
from patchwork.forms import PatchForm
from patchwork.models import Bundle
context = generic_list(request, project, 'patch-list',
view_args={'project_id': project.linkname})
- if is_authenticated(request.user):
+ if request.user.is_authenticated:
context['bundles'] = request.user.bundles.all()
return render(request, 'patchwork/list.html', context)
if editable:
form = PatchForm(instance=patch)
- if is_authenticated(request.user):
+ if request.user.is_authenticated:
createbundleform = CreateBundleForm()
if request.method == 'POST':
form.save()
messages.success(request, 'Patch updated')
- if is_authenticated(request.user):
+ if request.user.is_authenticated:
context['bundles'] = request.user.bundles.all()
context['submission'] = patch
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.models import Patch
from patchwork.models import Project
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from django.template.loader import render_to_string
+from django.urls import reverse
-from patchwork.compat import reverse
from patchwork.filters import DelegateFilter
from patchwork.forms import EmailForm
from patchwork.forms import RegistrationForm
from django.http import HttpResponseRedirect
from django.http import HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt
+from django.urls import reverse
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