Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
6b81210b
Commit
6b81210b
authored
Feb 02, 2016
by
Skia
Browse files
Fix permissions Mixins
parent
03bc0973
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/views/__init__.py
View file @
6b81210b
...
...
@@ -22,7 +22,8 @@ class CanEditPropMixin(View):
"""
def
dispatch
(
self
,
request
,
*
arg
,
**
kwargs
):
res
=
super
(
CanEditPropMixin
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
if
self
.
object
is
None
or
self
.
request
.
user
.
is_owner
(
self
.
object
):
if
((
hasattr
(
self
,
'object'
)
and
(
self
.
object
is
None
or
self
.
request
.
user
.
is_owner
(
self
.
object
)))
or
(
hasattr
(
self
,
'object_list'
)
and
(
self
.
object_list
is
None
or
self
.
object_list
is
[]
or
self
.
request
.
user
.
is_owner
(
self
.
object_list
[
0
])))):
return
res
try
:
# Always unlock when 403
self
.
object
.
unset_lock
()
...
...
@@ -37,7 +38,8 @@ class CanEditMixin(View):
def
dispatch
(
self
,
request
,
*
arg
,
**
kwargs
):
# TODO: WIP: fix permissions with exceptions!
res
=
super
(
CanEditMixin
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
if
self
.
object
is
None
or
self
.
request
.
user
.
can_edit
(
self
.
object
):
if
((
hasattr
(
self
,
'object'
)
and
(
self
.
object
is
None
or
self
.
request
.
user
.
can_edit
(
self
.
object
)))
or
(
hasattr
(
self
,
'object_list'
)
and
(
self
.
object_list
is
None
or
self
.
object_list
is
[]
or
self
.
request
.
user
.
can_edit
(
self
.
object_list
[
0
])))):
return
res
try
:
# Always unlock when 403
self
.
object
.
unset_lock
()
...
...
@@ -52,7 +54,8 @@ class CanViewMixin(View):
"""
def
dispatch
(
self
,
request
,
*
arg
,
**
kwargs
):
res
=
super
(
CanViewMixin
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
if
self
.
object
is
None
or
self
.
request
.
user
.
can_view
(
self
.
object
):
if
((
hasattr
(
self
,
'object'
)
and
(
self
.
object
is
None
or
self
.
request
.
user
.
can_view
(
self
.
object
)))
or
(
hasattr
(
self
,
'object_list'
)
and
(
self
.
object_list
is
None
or
self
.
object_list
is
[]
or
self
.
request
.
user
.
can_view
(
self
.
object_list
[
0
])))):
return
res
try
:
# Always unlock when 403
self
.
object
.
unset_lock
()
...
...
Write
Preview
Supports
Markdown
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