This raises a warning in Django 1.10 and will cause an error in 2.0.
This resolves all issues with Django 1.9.
Signed-off-by: Stephen Finucane <stephen@that.guru>
from patchwork.api.base import PatchworkPermission
from patchwork.api.filters import BundleFilter
+from patchwork.compat import is_authenticated
from patchwork.models import Bundle
serializer_class = BundleSerializer
def get_queryset(self):
- if not self.request.user.is_anonymous():
+ if is_authenticated(self.request.user):
bundle_filter = Q(owner=self.request.user) | Q(public=True)
else:
bundle_filter = Q(public=True)
else:
from django.core.urlresolvers import NoReverseMatch # noqa
from django.core.urlresolvers import reverse # 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.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
+from patchwork.compat import is_authenticated
from patchwork.fields import HashField
from patchwork.hasher import hash_diff
use_tags = models.BooleanField(default=True)
def is_editable(self, user):
- if not user.is_authenticated():
+ if not is_authenticated(user):
return False
return self in user.profile.maintainer_projects.all()
self.refresh_tag_counts()
def is_editable(self, user):
- if not user.is_authenticated():
+ if not is_authenticated(user):
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 request.user.is_authenticated():
+ if is_authenticated(request.user):
items_per_page = request.user.profile.items_per_page
super(Paginator, self).__init__(objects, items_per_page)
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 user.is_authenticated():
+ if is_authenticated(user):
# we only pass the post data to the MultiplePatchForm if that was
# the actual form submitted
data_tmp = None
from django.shortcuts import render
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
if editable:
form = PatchForm(instance=patch)
- if request.user.is_authenticated():
+ if is_authenticated(request.user):
createbundleform = CreateBundleForm()
if request.method == 'POST':
form.save()
messages.success(request, 'Patch updated')
- if request.user.is_authenticated():
+ if is_authenticated(request.user):
context['bundles'] = Bundle.objects.filter(owner=request.user)
context['submission'] = patch