Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions raven/contrib/django/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import time
import logging

from django import VERSION as DJANGO_VERSION
from django.conf import settings
from django.core.exceptions import SuspiciousOperation
from django.http import HttpRequest
Expand All @@ -37,6 +38,14 @@
__all__ = ('DjangoClient',)


if DJANGO_VERSION < (1, 10):
def is_authenticated(request_user):
return request_user.is_authenticated()
else:
def is_authenticated(request_user):
return request_user.is_authenticated


class _FormatConverter(object):

def __init__(self, param_mapping):
Expand Down Expand Up @@ -152,15 +161,9 @@ def get_user_info(self, request):
return user_info

try:
if hasattr(user, 'is_authenticated'):
# is_authenticated was a method in Django < 1.10
if callable(user.is_authenticated):
authenticated = user.is_authenticated()
else:
authenticated = user.is_authenticated
if not authenticated:
return user_info

authenticated = is_authenticated(user)
if not authenticated:
return user_info
user_info['id'] = user.pk

if hasattr(user, 'email'):
Expand Down