Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
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
Hide 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):
...
@@ -214,10 +214,10 @@ class AclBase(Model):
return
cls
.
objects
.
filter
(
clsfilter
)
return
cls
.
objects
.
filter
(
clsfilter
)
def
save
(
self
,
*
args
,
**
kwargs
):
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
)
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
:
class
Meta
:
abstract
=
True
abstract
=
True
circle/acl/tests/models.py
View file @
d400a069
...
@@ -22,4 +22,5 @@ class Test2Model(AclBase):
...
@@ -22,4 +22,5 @@ class Test2Model(AclBase):
(
'one'
,
'One'
),
(
'one'
,
'One'
),
(
'two'
,
'Two'
),
(
'two'
,
'Two'
),
(
'three'
,
'Three'
),
(
'three'
,
'Three'
),
(
'owner'
,
'owner'
),
)
)
circle/acl/tests/test_acl.py
View file @
d400a069
...
@@ -180,3 +180,33 @@ class AclUserTest(TestCase):
...
@@ -180,3 +180,33 @@ class AclUserTest(TestCase):
TestModel
.
get_objects_with_group_level
(
'alfa'
,
self
.
g1
),
[
i1
,
i2
])
TestModel
.
get_objects_with_group_level
(
'alfa'
,
self
.
g1
),
[
i1
,
i2
])
self
.
assertItemsEqual
(
self
.
assertItemsEqual
(
TestModel
.
get_objects_with_group_level
(
'alfa'
,
self
.
g2
),
[
i2
])
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