Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
insights
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
insights
Commits
6bcf971f
Commit
6bcf971f
authored
Apr 19, 2013
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Policy transforms work
parent
21c8f60c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
src/djanalytics/core/djobject.py
+15
-6
No files found.
src/djanalytics/core/djobject.py
View file @
6bcf971f
...
@@ -118,15 +118,25 @@ class embed():
...
@@ -118,15 +118,25 @@ class embed():
return
self
.
_view_or_query
+
" object host: ["
+
self
.
_baseurl
+
"]"
return
self
.
_view_or_query
+
" object host: ["
+
self
.
_baseurl
+
"]"
class
transform_embed
:
class
transform_embed
:
def
__init__
(
self
,
transform_policy
,
embed
):
def
__init__
(
self
,
transform_policy
,
context
,
embed
):
self
.
_embed
=
embed
self
.
_embed
=
embed
self
.
_context
=
context
self
.
_transform_policy
=
transform_policy
self
.
_transform_policy
=
transform_policy
def
_transform
(
self
,
function
,
stripped_args
):
def
new_helper
(
**
kwargs
):
args
=
kwargs
for
arg
in
stripped_args
:
args
[
arg
]
=
context
[
arg
]
return
function
(
**
args
)
## TODO: Update argspec
return
new_helper
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
if
attr
[
0
]
==
'_'
:
if
attr
[
0
]
==
'_'
:
return
return
permission
=
self
.
_permission
(
listing
)
permission
=
self
.
_permission
(
attr
)
if
permission
==
'allow'
:
if
permission
==
'allow'
:
return
self
.
_embed
.
__getattr__
(
attr
)
return
self
.
_embed
.
__getattr__
(
attr
)
elif
permission
==
'deny'
:
elif
permission
==
'deny'
:
...
@@ -144,8 +154,6 @@ class transform_embed:
...
@@ -144,8 +154,6 @@ class transform_embed:
listing
=
self
.
_embed
.
__dir__
()
listing
=
self
.
_embed
.
__dir__
()
filtered
=
[]
filtered
=
[]
for
item
in
listing
:
for
item
in
listing
:
# pseudocode
print
item
if
self
.
_permission
(
item
)
!=
'deny'
:
if
self
.
_permission
(
item
)
!=
'deny'
:
filtered
.
append
(
item
)
filtered
.
append
(
item
)
return
filtered
return
filtered
...
@@ -169,11 +177,12 @@ if __name__ == "__main__":
...
@@ -169,11 +177,12 @@ if __name__ == "__main__":
'policy'
:
{
'total_user_count'
:
'allow'
,
'policy'
:
{
'total_user_count'
:
'allow'
,
'user_count'
:
'allow'
,
'user_count'
:
'allow'
,
'dash'
:
'deny'
,
'dash'
:
'deny'
,
'page_count'
:
{
'user'
:
'$user'
}
}
'page_count'
:
[
'user'
]
}
}
}
context
=
{
'user'
:
'bob'
,
context
=
{
'user'
:
'bob'
,
'course'
:
'6.002x'
}
'course'
:
'6.002x'
}
secure_view
=
transform_embed
(
transform_policy
,
djo
.
view
)
secure_view
=
transform_embed
(
transform_policy
,
context
,
djo
.
view
)
print
secure_view
.
__dir__
()
print
secure_view
.
__dir__
()
print
secure_view
.
page_count
(
course
=
'6.002x'
)
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