"""
Possible functions for the ``PRIVATE_STORAGE_AUTH_FUNCTION`` setting.
"""


def allow_authenticated(private_file):
    try:
        return private_file.request.user.is_authenticated()
    except AttributeError:
        # Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
        return private_file.request.user.is_authenticated
    

def allow_staff(private_file):
    request = private_file.request
    try:
        return request.user.is_authenticated() and request.user.is_staff
    except AttributeError:
        # Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
        return request.user.is_authenticated and request.user.is_staff


def allow_superuser(private_file):
    request = private_file.request
    try:
        return request.user.is_authenticated() and request.user.is_superuser
    except AttributeError:
        # Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
        return request.user.is_authenticated and request.user.is_superuser

@@ -71,18 +71,65 @@
 ng.%0A%22%22%22%0A
-%0A%0A
+import django%0A%0Aif django.VERSION %3E= (1, 10):%0A    
 def allo
@@ -159,25 +159,16 @@
 _file):%0A
-    try:%0A
         
@@ -220,144 +220,83 @@
 ated
-()
+%0A
 %0A    
-except AttributeError:%0A        # Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
+def allow_staff(private_file):%0A        request = private_file.request
 %0A   
@@ -303,37 +303,24 @@
      return 
-private_file.
 request.user
@@ -340,15 +340,40 @@
 ated
+ and request.user.is_staff%0A
 %0A    
-%0A%0A
 def 
@@ -371,36 +371,40 @@
 %0A    def allow_s
-taff
+uperuser
 (private_file):%0A
@@ -399,32 +399,36 @@
 vate_file):%0A    
+  
+  
 request = privat
@@ -443,32 +443,23 @@
 equest%0A 
-   try:%0A
        
- 
 return r
@@ -478,34 +478,32 @@
 is_authenticated
-()
  and request.use
@@ -512,146 +512,65 @@
 is_s
-taff%0A    except AttributeError:%0A        # Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
+uperuser%0Aelse:%0A    def allow_authenticated(private_file):
 %0A   
@@ -573,32 +573,45 @@
 %0A        return 
+private_file.
 request.user.is_
@@ -627,37 +627,16 @@
 ated
- and request.user.is_staff%0A%0A%0A
+()%0A%0A    
 def 
@@ -638,32 +638,28 @@
  def allow_s
-uperuser
+taff
 (private_fil
@@ -658,24 +658,28 @@
 vate_file):%0A
+    
     request 
@@ -707,23 +707,14 @@
 t%0A  
-  try:%0A
       
-  
 retu
@@ -773,150 +773,91 @@
 is_s
-uperuser%0A    except AttributeError:%0A        # Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
+taff%0A%0A    def allow_superuser(private_file):%0A        request = private_file.request
 %0A   
@@ -889,32 +889,34 @@
 is_authenticated
+()
  and request.use

Change the permission checks, provide distinct versions for Django 1.10+