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
23fc9dd5
Commit
23fc9dd5
authored
Sep 09, 2013
by
bwreilly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better doc for object permissions, drop redundant has_permission call
parent
0183c695
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
rest_framework/permissions.py
+8
-7
No files found.
rest_framework/permissions.py
View file @
23fc9dd5
...
@@ -154,7 +154,14 @@ class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions):
...
@@ -154,7 +154,14 @@ class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions):
class
DjangoObjectLevelModelPermissions
(
DjangoModelPermissions
):
class
DjangoObjectLevelModelPermissions
(
DjangoModelPermissions
):
"""
"""
Basic object level permissions utilizing django-guardian.
The request is authenticated using `django.contrib.auth` permissions.
See: https://docs.djangoproject.com/en/dev/topics/auth/#permissions
It ensures that the user is authenticated, and has the appropriate
`add`/`change`/`delete` permissions on the object using .has_perms.
This permission can only be applied against view classes that
provide a `.model` or `.queryset` attribute.
"""
"""
actions_map
=
{
actions_map
=
{
...
@@ -173,12 +180,6 @@ class DjangoObjectLevelModelPermissions(DjangoModelPermissions):
...
@@ -173,12 +180,6 @@ class DjangoObjectLevelModelPermissions(DjangoModelPermissions):
}
}
return
[
perm
%
kwargs
for
perm
in
self
.
actions_map
[
method
]]
return
[
perm
%
kwargs
for
perm
in
self
.
actions_map
[
method
]]
def
has_permission
(
self
,
request
,
view
):
if
getattr
(
view
,
'action'
,
None
)
==
'list'
:
queryset
=
view
.
get_queryset
()
view
.
queryset
=
ObjectPermissionReaderFilter
()
.
filter_queryset
(
request
,
queryset
,
view
)
return
super
(
DjangoObjectLevelModelPermissions
,
self
)
.
has_permission
(
request
,
view
)
def
has_object_permission
(
self
,
request
,
view
,
obj
):
def
has_object_permission
(
self
,
request
,
view
,
obj
):
model_cls
=
getattr
(
view
,
'model'
,
None
)
model_cls
=
getattr
(
view
,
'model'
,
None
)
queryset
=
getattr
(
view
,
'queryset'
,
None
)
queryset
=
getattr
(
view
,
'queryset'
,
None
)
...
...
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