Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
11a83b1e
Commit
11a83b1e
authored
5 years ago
by
Alexandre Bourlier
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: AnonymousReadOnly
parent
10c7a2f0
No related branches found
Branches containing commit
Tags
v0.8.0-beta.1
Tags containing commit
1 merge request
!70
bugfix: AnonymousReadOnly
Pipeline
#964
passed
5 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp/permissions.py
+8
-11
8 additions, 11 deletions
djangoldp/permissions.py
with
8 additions
and
11 deletions
djangoldp/permissions.py
+
8
−
11
View file @
11a83b1e
...
@@ -80,10 +80,10 @@ class InboxPermissions(WACPermissions):
...
@@ -80,10 +80,10 @@ class InboxPermissions(WACPermissions):
return
super
().
has_object_permission
(
request
,
view
,
obj
)
return
super
().
has_object_permission
(
request
,
view
,
obj
)
def
user_permissions
(
self
,
user
,
obj
):
def
user_permissions
(
self
,
user
,
obj
):
if
user
.
is_anonymous
:
if
user
.
is_anonymous
()
:
return
self
.
anonymous_perms
return
self
.
anonymous_perms
else
:
else
:
if
Model
.
get_meta
(
obj
,
'
auto_author
'
)
==
user
:
if
hasattr
(
obj
.
_meta
,
'
auto_author
'
)
and
getattr
(
obj
,
Model
.
get_meta
(
obj
,
'
auto_author
'
)
)
==
user
:
return
self
.
author_perms
return
self
.
author_perms
else
:
else
:
return
self
.
authenticated_perms
return
self
.
authenticated_perms
...
@@ -114,18 +114,15 @@ class AnonymousReadOnly(WACPermissions):
...
@@ -114,18 +114,15 @@ class AnonymousReadOnly(WACPermissions):
elif
view
.
action
in
[
"
list
"
,
"
retrieve
"
]:
elif
view
.
action
in
[
"
list
"
,
"
retrieve
"
]:
return
True
return
True
elif
view
.
action
in
[
'
update
'
,
'
partial_update
'
,
'
destroy
'
]:
elif
view
.
action
in
[
'
update
'
,
'
partial_update
'
,
'
destroy
'
]:
if
hasattr
(
obj
.
_meta
,
'
auto_author
'
):
if
hasattr
(
obj
.
_meta
,
'
auto_author
'
)
and
getattr
(
obj
,
Model
.
get_meta
(
obj
,
'
auto_author
'
))
==
request
.
user
:
author
=
getattr
(
obj
,
obj
.
_meta
.
auto_author
)
return
True
if
author
==
request
.
user
:
return
super
().
has_object_permission
(
request
,
view
,
obj
)
return
True
else
:
return
super
().
has_object_permission
(
request
,
view
,
obj
)
def
user_permissions
(
self
,
user
,
obj
):
def
user_permissions
(
self
,
user
,
obj
):
if
user
.
is_anonymous
:
if
user
.
is_anonymous
()
:
return
self
.
anonymous_perms
return
self
.
anonymous_perms
else
:
else
:
if
Model
.
get_meta
(
obj
,
'
auto_author
'
)
==
user
:
if
hasattr
(
obj
.
_meta
,
'
auto_author
'
)
and
getattr
(
obj
,
Model
.
get_meta
(
obj
,
'
auto_author
'
)
)
==
user
:
return
self
.
author_perms
return
self
.
author_perms
else
:
else
:
return
self
.
authenticated_perms
return
self
.
authenticated_perms
...
@@ -153,7 +150,7 @@ class LoggedReadOnly(WACPermissions):
...
@@ -153,7 +150,7 @@ class LoggedReadOnly(WACPermissions):
return
super
().
has_object_permission
(
request
,
view
,
obj
)
return
super
().
has_object_permission
(
request
,
view
,
obj
)
def
user_permissions
(
self
,
user
,
obj
):
def
user_permissions
(
self
,
user
,
obj
):
if
user
.
is_anonymous
:
if
user
.
is_anonymous
()
:
return
self
.
anonymous_perms
return
self
.
anonymous_perms
else
:
else
:
return
self
.
authenticated_perms
return
self
.
authenticated_perms
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment