Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d400a069
authored
Feb 11, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
acl: fix and test auto-owner functionality
parent
61deebe3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
circle/acl/models.py
+3
-3
circle/acl/tests/models.py
+1
-0
circle/acl/tests/test_acl.py
+30
-0
No files found.
circle/acl/models.py
View file @
d400a069
...
...
@@ -214,10 +214,10 @@ class AclBase(Model):
return
cls
.
objects
.
filter
(
clsfilter
)
def
save
(
self
,
*
args
,
**
kwargs
):
if
'owner'
in
self
and
self
.
owner
and
'owner'
in
self
.
ACL_LEVELS
:
self
.
set_user_level
(
self
.
owner
,
'owner'
)
super
(
AclBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
if
'owner'
in
dict
(
self
.
ACL_LEVELS
)
and
(
hasattr
(
self
,
'owner'
)
and
self
.
owner
):
self
.
set_user_level
(
self
.
owner
,
'owner'
)
class
Meta
:
abstract
=
True
circle/acl/tests/models.py
View file @
d400a069
...
...
@@ -22,4 +22,5 @@ class Test2Model(AclBase):
(
'one'
,
'One'
),
(
'two'
,
'Two'
),
(
'three'
,
'Three'
),
(
'owner'
,
'owner'
),
)
circle/acl/tests/test_acl.py
View file @
d400a069
...
...
@@ -180,3 +180,33 @@ class AclUserTest(TestCase):
TestModel
.
get_objects_with_group_level
(
'alfa'
,
self
.
g1
),
[
i1
,
i2
])
self
.
assertItemsEqual
(
TestModel
.
get_objects_with_group_level
(
'alfa'
,
self
.
g2
),
[
i2
])
def
test_owner
(
self
):
i
=
Test2Model
.
objects
.
create
(
normal2_field
=
'Hello'
,
owner
=
self
.
u1
)
self
.
assertTrue
(
i
.
has_level
(
self
.
u1
,
'one'
))
self
.
assertTrue
(
i
.
has_level
(
self
.
u1
,
'owner'
))
self
.
assertFalse
(
i
.
has_level
(
self
.
u2
,
'owner'
))
def
test_owner_change
(
self
):
i
=
Test2Model
.
objects
.
create
(
normal2_field
=
'Hello'
,
owner
=
self
.
u1
)
self
.
assertTrue
(
i
.
has_level
(
self
.
u1
,
'one'
))
self
.
assertTrue
(
i
.
has_level
(
self
.
u1
,
'owner'
))
self
.
assertFalse
(
i
.
has_level
(
self
.
u2
,
'owner'
))
i
.
owner
=
self
.
u2
i
.
save
()
self
.
assertTrue
(
i
.
has_level
(
self
.
u1
,
'one'
))
self
.
assertTrue
(
i
.
has_level
(
self
.
u1
,
'owner'
))
self
.
assertTrue
(
i
.
has_level
(
self
.
u2
,
'owner'
))
def
test_owner_change_from_none
(
self
):
i
=
Test2Model
.
objects
.
create
(
normal2_field
=
'Hello'
)
self
.
assertFalse
(
i
.
has_level
(
self
.
u1
,
'one'
))
self
.
assertFalse
(
i
.
has_level
(
self
.
u1
,
'owner'
))
self
.
assertFalse
(
i
.
has_level
(
self
.
u2
,
'owner'
))
i
.
owner
=
self
.
u2
i
.
save
()
self
.
assertFalse
(
i
.
has_level
(
self
.
u1
,
'one'
))
self
.
assertFalse
(
i
.
has_level
(
self
.
u1
,
'owner'
))
self
.
assertTrue
(
i
.
has_level
(
self
.
u2
,
'owner'
))
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