This repository was archived by the owner on Oct 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 1212import time
1313import logging
1414
15+ from django import VERSION as DJANGO_VERSION
1516from django .conf import settings
1617from django .core .exceptions import SuspiciousOperation
1718from django .http import HttpRequest
3738__all__ = ('DjangoClient' ,)
3839
3940
41+ if DJANGO_VERSION < (1 , 10 ):
42+ def is_authenticated (request_user ):
43+ return request_user .is_authenticated ()
44+ else :
45+ def is_authenticated (request_user ):
46+ return request_user .is_authenticated
47+
48+
4049class _FormatConverter (object ):
4150
4251 def __init__ (self , param_mapping ):
@@ -152,15 +161,9 @@ def get_user_info(self, request):
152161 return user_info
153162
154163 try :
155- if hasattr (user , 'is_authenticated' ):
156- # is_authenticated was a method in Django < 1.10
157- if callable (user .is_authenticated ):
158- authenticated = user .is_authenticated ()
159- else :
160- authenticated = user .is_authenticated
161- if not authenticated :
162- return user_info
163-
164+ authenticated = is_authenticated (user )
165+ if not authenticated :
166+ return user_info
164167 user_info ['id' ] = user .pk
165168
166169 if hasattr (user , 'email' ):
You can’t perform that action at this time.
0 commit comments