Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
+9
-14
circle/acl/models.py
+9
-14
No files found.
circle/acl/models.py
View file @
ca0b8a5e
...
...
@@ -54,10 +54,11 @@ class AclBase(Model):
"""Define permission levels for Users/Groups per object."""
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."""
ct
=
ContentType
.
objects
.
get_for_model
(
self
)
ct
=
ContentType
.
objects
.
get_for_model
(
cls
)
return
Level
.
objects
.
get
(
codename
=
level
,
content_type
=
ct
)
def
set_level
(
self
,
whom
,
level
):
...
...
@@ -133,18 +134,12 @@ class AclBase(Model):
object_levels
=
self
.
object_level_set
.
filter
(
level__weight__gte
=
level
.
weight
)
.
all
()
if
group_also
:
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
:
if
i
.
users
.
filter
(
pk
=
user
.
pk
)
.
exists
():
return
True
if
(
group_also
and
i
.
groups
.
filter
(
pk__in
=
groups
)
.
exists
()):
return
True
groups
=
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
if
group_also
else
[]
for
i
in
object_levels
:
if
i
.
users
.
filter
(
pk
=
user
.
pk
)
.
exists
():
return
True
if
group_also
and
i
.
groups
.
filter
(
pk__in
=
groups
)
.
exists
():
return
True
return
False
def
get_users_with_level
(
self
):
...
...
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