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
6d0e2b21
Commit
6d0e2b21
authored
May 21, 2014
by
zubair-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update _xmodule_recurse method
parent
6bdf984e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
15 deletions
+10
-15
cms/djangoapps/contentstore/views/helpers.py
+7
-12
cms/djangoapps/contentstore/views/item.py
+3
-3
No files found.
cms/djangoapps/contentstore/views/helpers.py
View file @
6d0e2b21
...
...
@@ -4,7 +4,6 @@ from django.http import HttpResponse
from
django.shortcuts
import
redirect
from
edxmako.shortcuts
import
render_to_string
,
render_to_response
from
xmodule.modulestore.django
import
loc_mapper
,
modulestore
from
xmodule.modulestore.exceptions
import
DuplicateItemError
,
ItemNotFoundError
__all__
=
[
'edge'
,
'event'
,
'landing'
]
...
...
@@ -37,24 +36,20 @@ def render_from_lms(template_name, dictionary, context=None, namespace='main'):
return
render_to_string
(
template_name
,
dictionary
,
context
,
namespace
=
"lms."
+
namespace
)
def
_xmodule_recurse
(
item
,
action
,
ignore_exception
=
None
):
def
_xmodule_recurse
(
item
,
action
,
ignore_exception
=
()
):
"""
Recursively apply provided action on item and its children
ignore_
duplicate_exception (str): A optional argument; when set to a certain value then
ignores the corresponding
exception raised
while xmodule recursion
ignore_
exception (Exception Object): A optional argument; when passed
ignores the corresponding
exception raised
during xmodule recursion,
"""
for
child
in
item
.
get_children
():
_xmodule_recurse
(
child
,
action
,
ignore_exception
)
if
ignore_exception
in
[
'ItemNotFoundError'
,
'DuplicateItemError'
]:
# In case of valid provided exception; ignore it and continue recursion
try
:
return
action
(
item
)
except
(
ItemNotFoundError
,
DuplicateItemError
):
return
action
(
item
)
try
:
return
action
(
item
)
except
ignore_exception
:
return
def
get_parent_xblock
(
xblock
):
...
...
cms/djangoapps/contentstore/views/item.py
View file @
6d0e2b21
...
...
@@ -21,7 +21,7 @@ from xblock.fragment import Fragment
import
xmodule
from
xmodule.modulestore.django
import
modulestore
,
loc_mapper
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InvalidLocationError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InvalidLocationError
,
DuplicateItemError
from
xmodule.modulestore.inheritance
import
own_metadata
from
xmodule.modulestore.locator
import
BlockUsageLocator
from
xmodule.modulestore
import
Location
...
...
@@ -313,7 +313,7 @@ def _save_item(request, usage_loc, item_location, data=None, children=None, meta
_xmodule_recurse
(
existing_item
,
lambda
i
:
modulestore
()
.
unpublish
(
i
.
location
),
ignore_exception
=
'ItemNotFoundError'
ignore_exception
=
ItemNotFoundError
)
elif
publish
==
'create_draft'
:
# This recursively clones the existing item location to a draft location (the draft is
...
...
@@ -321,7 +321,7 @@ def _save_item(request, usage_loc, item_location, data=None, children=None, meta
_xmodule_recurse
(
existing_item
,
lambda
i
:
modulestore
()
.
convert_to_draft
(
i
.
location
),
ignore_exception
=
'DuplicateItemError'
ignore_exception
=
DuplicateItemError
)
if
data
:
...
...
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