Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
e95e5e70
Commit
e95e5e70
authored
Apr 03, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed RCB recursive copy function to private function.
parent
5bf2c23f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
common/lib/xmodule/xmodule/library_content_module.py
+20
-16
No files found.
common/lib/xmodule/xmodule/library_content_module.py
View file @
e95e5e70
...
@@ -343,9 +343,26 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
...
@@ -343,9 +343,26 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
"""
"""
user_perms
=
self
.
runtime
.
service
(
self
,
'studio_user_permissions'
)
user_perms
=
self
.
runtime
.
service
(
self
,
'studio_user_permissions'
)
user_id
=
self
.
get_user_id
()
user_id
=
self
.
get_user_id
()
if
not
self
.
tools
:
return
Response
(
"Library Tools unavailable in current runtime."
,
status
=
400
)
self
.
tools
.
update_children
(
self
,
user_id
,
user_perms
)
self
.
tools
.
update_children
(
self
,
user_id
,
user_perms
)
return
Response
()
return
Response
()
# Copy over any overridden settings the course author may have applied to the blocks.
def
_copy_overrides
(
self
,
store
,
user_id
,
source
,
dest
):
"""
Copy any overrides the user has made on blocks in this library.
"""
for
field
in
source
.
fields
.
itervalues
():
if
field
.
scope
==
Scope
.
settings
and
field
.
is_set_on
(
source
):
setattr
(
dest
,
field
.
name
,
field
.
read_from
(
source
))
if
source
.
has_children
:
source_children
=
[
self
.
runtime
.
get_block
(
source_key
)
for
source_key
in
source
.
children
]
dest_children
=
[
self
.
runtime
.
get_block
(
dest_key
)
for
dest_key
in
dest
.
children
]
for
source_child
,
dest_child
in
zip
(
source_children
,
dest_children
):
self
.
_copy_overrides
(
store
,
user_id
,
source_child
,
dest_child
)
store
.
update_item
(
dest
,
user_id
)
def
studio_post_duplicate
(
self
,
store
,
source_block
):
def
studio_post_duplicate
(
self
,
store
,
source_block
):
"""
"""
Used by the studio after basic duplication of a source block. We handle the children
Used by the studio after basic duplication of a source block. We handle the children
...
@@ -359,24 +376,11 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
...
@@ -359,24 +376,11 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
user_id
=
self
.
get_user_id
()
user_id
=
self
.
get_user_id
()
user_perms
=
self
.
runtime
.
service
(
self
,
'studio_user_permissions'
)
user_perms
=
self
.
runtime
.
service
(
self
,
'studio_user_permissions'
)
# pylint: disable=no-member
# pylint: disable=no-member
if
not
self
.
tools
:
raise
RuntimeError
(
"Library tools unavailable, duplication will not be sane!"
)
self
.
tools
.
update_children
(
self
,
user_id
,
user_perms
,
version
=
self
.
source_library_version
)
self
.
tools
.
update_children
(
self
,
user_id
,
user_perms
,
version
=
self
.
source_library_version
)
# Copy over any overridden settings the course author may have applied to the blocks.
self
.
_copy_overrides
(
store
,
user_id
,
source_block
,
self
)
def
copy_overrides
(
source
,
dest
):
"""
Copy any overrides the user has made on blocks in this library.
"""
for
field
in
source
.
fields
.
itervalues
():
if
field
.
scope
==
Scope
.
settings
and
field
.
is_set_on
(
source
):
setattr
(
dest
,
field
.
name
,
field
.
read_from
(
source
))
if
source
.
has_children
:
source_children
=
[
self
.
runtime
.
get_block
(
source_key
)
for
source_key
in
source
.
children
]
dest_children
=
[
self
.
runtime
.
get_block
(
dest_key
)
for
dest_key
in
dest
.
children
]
for
source_child
,
dest_child
in
zip
(
source_children
,
dest_children
):
copy_overrides
(
source_child
,
dest_child
)
store
.
update_item
(
dest
,
user_id
)
copy_overrides
(
source_block
,
self
)
# Children have been handled.
# Children have been handled.
return
True
return
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