Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
9b7341e4
Commit
9b7341e4
authored
Dec 22, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1312 from amatellanes/master
Simplified some functions in permissions.py
parents
b7482629
2d6d725c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
rest_framework/permissions.py
+6
-14
No files found.
rest_framework/permissions.py
View file @
9b7341e4
...
...
@@ -54,9 +54,7 @@ class IsAuthenticated(BasePermission):
"""
def
has_permission
(
self
,
request
,
view
):
if
request
.
user
and
request
.
user
.
is_authenticated
():
return
True
return
False
return
request
.
user
and
request
.
user
.
is_authenticated
()
class
IsAdminUser
(
BasePermission
):
...
...
@@ -65,9 +63,7 @@ class IsAdminUser(BasePermission):
"""
def
has_permission
(
self
,
request
,
view
):
if
request
.
user
and
request
.
user
.
is_staff
:
return
True
return
False
return
request
.
user
and
request
.
user
.
is_staff
class
IsAuthenticatedOrReadOnly
(
BasePermission
):
...
...
@@ -76,11 +72,9 @@ class IsAuthenticatedOrReadOnly(BasePermission):
"""
def
has_permission
(
self
,
request
,
view
):
if
(
request
.
method
in
SAFE_METHODS
or
return
(
request
.
method
in
SAFE_METHODS
or
request
.
user
and
request
.
user
.
is_authenticated
()):
return
True
return
False
request
.
user
.
is_authenticated
())
class
DjangoModelPermissions
(
BasePermission
):
...
...
@@ -138,11 +132,9 @@ class DjangoModelPermissions(BasePermission):
perms
=
self
.
get_required_permissions
(
request
.
method
,
model_cls
)
if
(
request
.
user
and
return
(
request
.
user
and
(
request
.
user
.
is_authenticated
()
or
not
self
.
authenticated_users_only
)
and
request
.
user
.
has_perms
(
perms
)):
return
True
return
False
request
.
user
.
has_perms
(
perms
))
class
DjangoModelPermissionsOrAnonReadOnly
(
DjangoModelPermissions
):
...
...
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