Unverified Commit cc35a590 authored by Mikhail Vagin's avatar Mikhail Vagin Committed by GitHub
Browse files

Django 2.0 support for permissions.py

Using user.is_authenticated() and user.is_anonymous() as a method is deprecated since Django 2.0
parent be3ade29
......@@ -4,14 +4,26 @@ Possible functions for the ``PRIVATE_STORAGE_AUTH_FUNCTION`` setting.
def allow_authenticated(private_file):
return private_file.request.user.is_authenticated()
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
return request.user.is_authenticated() and request.user.is_staff
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
return request.user.is_authenticated() and request.user.is_superuser
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment