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
c48f9e72
authored
Dec 17, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'acl-getobject' of /home/git/repositories/circle/cloud
parents
1ef8dbd6
ee7fa85e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletions
+19
-1
circle/acl/models.py
+19
-1
No files found.
circle/acl/models.py
View file @
c48f9e72
...
...
@@ -6,7 +6,7 @@ from django.contrib.contenttypes.generic import (
)
from
django.contrib.contenttypes.models
import
ContentType
from
django.db.models
import
(
ManyToManyField
,
ForeignKey
,
CharField
,
Model
,
IntegerField
ManyToManyField
,
ForeignKey
,
CharField
,
Model
,
IntegerField
,
Q
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -175,5 +175,23 @@ class AclBase(Model):
logger
.
debug
(
'-
%
s:
%
s'
%
(
name
,
[
g
.
name
for
g
in
olgroups
]))
return
groups
@classmethod
def
get_objects_with_level
(
cls
,
level
,
user
):
logger
.
debug
(
'
%
s.get_objects_with_level(
%
s,
%
s) called'
,
unicode
(
cls
),
unicode
(
level
),
unicode
(
user
))
if
user
is
None
or
not
user
.
is_authenticated
():
return
cls
.
objects
.
none
()
if
getattr
(
user
,
'is_superuser'
,
False
):
logger
.
debug
(
'- superuser granted'
)
return
cls
.
objects
if
isinstance
(
level
,
basestring
):
level
=
cls
.
get_level_object
(
level
)
logger
.
debug
(
"- level set by str:
%
s"
,
unicode
(
level
))
ct
=
ContentType
.
objects
.
get_for_model
(
cls
)
return
user
.
objectlevel_set
.
filter
(
Q
(
users
=
user
)
|
Q
(
groups__in
=
user
.
groups
.
all
()),
content_type
=
ct
,
level__weight__gte
=
level
.
weight
)
.
distinct
()
class
Meta
:
abstract
=
True
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