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
ca0b8a5e
authored
Nov 09, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
acl: fixing bugs discovered by tests
parent
110d579b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
circle/acl/models.py
+5
-10
No files found.
circle/acl/models.py
View file @
ca0b8a5e
...
@@ -54,10 +54,11 @@ class AclBase(Model):
...
@@ -54,10 +54,11 @@ class AclBase(Model):
"""Define permission levels for Users/Groups per object."""
"""Define permission levels for Users/Groups per object."""
object_level_set
=
GenericRelation
(
ObjectLevel
)
object_level_set
=
GenericRelation
(
ObjectLevel
)
def
get_level_object
(
self
,
level
):
@classmethod
def
get_level_object
(
cls
,
level
):
"""Get Level object for this model by codename."""
"""Get Level object for this model by codename."""
ct
=
ContentType
.
objects
.
get_for_model
(
self
)
ct
=
ContentType
.
objects
.
get_for_model
(
cls
)
return
Level
.
objects
.
get
(
codename
=
level
,
content_type
=
ct
)
return
Level
.
objects
.
get
(
codename
=
level
,
content_type
=
ct
)
def
set_level
(
self
,
whom
,
level
):
def
set_level
(
self
,
whom
,
level
):
...
@@ -133,17 +134,11 @@ class AclBase(Model):
...
@@ -133,17 +134,11 @@ class AclBase(Model):
object_levels
=
self
.
object_level_set
.
filter
(
object_levels
=
self
.
object_level_set
.
filter
(
level__weight__gte
=
level
.
weight
)
.
all
()
level__weight__gte
=
level
.
weight
)
.
all
()
if
group_also
:
groups
=
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
if
group_also
else
[]
try
:
groups
=
user
.
group_set
.
values_list
(
'id'
,
flat
=
True
)
except
AttributeError
:
pass
# e.g. AnyonymousUser doesn't have group_set
else
:
for
i
in
object_levels
:
for
i
in
object_levels
:
if
i
.
users
.
filter
(
pk
=
user
.
pk
)
.
exists
():
if
i
.
users
.
filter
(
pk
=
user
.
pk
)
.
exists
():
return
True
return
True
if
(
group_also
and
if
group_also
and
i
.
groups
.
filter
(
pk__in
=
groups
)
.
exists
():
i
.
groups
.
filter
(
pk__in
=
groups
)
.
exists
()):
return
True
return
True
return
False
return
False
...
...
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