Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
8c75327d
Commit
8c75327d
authored
Feb 06, 2018
by
Diederik van der Boor
Browse files
Change the permission checks, provide distinct versions for Django 1.10+
parent
4b69c2ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
private_storage/permissions.py
View file @
8c75327d
"""
"""
Possible functions for the ``PRIVATE_STORAGE_AUTH_FUNCTION`` setting.
Possible functions for the ``PRIVATE_STORAGE_AUTH_FUNCTION`` setting.
"""
"""
import
django
if
django
.
VERSION
>=
(
1
,
10
):
def
allow_authenticated
(
private_file
):
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
return
private_file
.
request
.
user
.
is_authenticated
def
allow_staff
(
private_file
):
def
allow_staff
(
private_file
):
request
=
private_file
.
request
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
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
else
:
def
allow_authenticated
(
private_file
):
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
def
allow_superuser
(
private_file
):
def
allow_superuser
(
private_file
):
request
=
private_file
.
request
request
=
private_file
.
request
try
:
return
request
.
user
.
is_authenticated
()
and
request
.
user
.
is_superuser
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment