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
7e458582
Commit
7e458582
authored
Jan 12, 2015
by
Adam Palay
Browse files
Options
Browse Files
Download
Plain Diff
resolve merge conflicts between release and master
parents
75a26a7e
0435289a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
7 deletions
+48
-7
cms/djangoapps/contentstore/management/commands/fix_not_found.py
+27
-0
common/lib/xmodule/xmodule/modulestore/split_migrator.py
+1
-1
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+10
-6
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
+10
-0
No files found.
cms/djangoapps/contentstore/management/commands/fix_not_found.py
0 → 100644
View file @
7e458582
"""
Script for fixing the item not found errors in a course
"""
from
django.core.management.base
import
BaseCommand
,
CommandError
from
opaque_keys.edx.keys
import
CourseKey
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
ModuleStoreEnum
# To run from command line: ./manage.py cms fix_not_found course-v1:org+course+run
class
Command
(
BaseCommand
):
"""Fix a course's item not found errors"""
help
=
"Fix a course's ItemNotFound errors"
def
handle
(
self
,
*
args
,
**
options
):
"Execute the command"
if
len
(
args
)
!=
1
:
raise
CommandError
(
"requires 1 argument: <course_id>"
)
course_key
=
CourseKey
.
from_string
(
args
[
0
])
# for now only support on split mongo
owning_store
=
modulestore
()
.
_get_modulestore_for_courseid
(
course_key
)
if
hasattr
(
owning_store
,
'fix_not_found'
):
owning_store
.
fix_not_found
(
course_key
,
ModuleStoreEnum
.
UserID
.
mgmt_command
)
else
:
raise
CommandError
(
"The owning modulestore does not support this command."
)
common/lib/xmodule/xmodule/modulestore/split_migrator.py
View file @
7e458582
...
...
@@ -119,7 +119,7 @@ class SplitMigrator(object):
# clean up orphans in published version: in old mongo, parents pointed to the union of their published and draft
# children which meant some pointers were to non-existent locations in 'direct'
self
.
split_modulestore
.
internal_clean_children
(
course_version_locator
)
self
.
split_modulestore
.
fix_not_found
(
course_version_locator
,
user_id
)
def
_add_draft_modules_to_course
(
self
,
published_course_usage_key
,
source_course_key
,
user_id
,
**
kwargs
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
7e458582
...
...
@@ -2418,22 +2418,26 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
# update the index entry if appropriate
self
.
_update_head
(
dest_course_key
,
index_entry
,
dest_course_key
.
branch
,
new_structure
[
'_id'
])
def
internal_clean_children
(
self
,
course_locator
):
def
fix_not_found
(
self
,
course_locator
,
user_id
):
"""
Only intended for rather low level methods to use. Goes through the children attrs of
each block removing any whose block_id is not a member of the course. Does not generate
a new version of the course but overwrites the existing one.
each block removing any whose block_id is not a member of the course.
:param course_locator: the course to clean
"""
original_structure
=
self
.
_lookup_course
(
course_locator
)
.
structure
for
block
in
original_structure
[
'blocks'
]
.
itervalues
():
index_entry
=
self
.
_get_index_if_valid
(
course_locator
)
new_structure
=
self
.
version_structure
(
course_locator
,
original_structure
,
user_id
)
for
block
in
new_structure
[
'blocks'
]
.
itervalues
():
if
'fields'
in
block
and
'children'
in
block
[
'fields'
]:
block
[
'fields'
][
"children"
]
=
[
block_id
for
block_id
in
block
[
'fields'
][
"children"
]
if
block_id
in
original
_structure
[
'blocks'
]
if
block_id
in
new
_structure
[
'blocks'
]
]
self
.
update_structure
(
course_locator
,
original_structure
)
self
.
update_structure
(
course_locator
,
new_structure
)
if
index_entry
is
not
None
:
# update the index entry if appropriate
self
.
_update_head
(
course_locator
,
index_entry
,
course_locator
.
branch
,
new_structure
[
'_id'
])
def
convert_references_to_keys
(
self
,
course_key
,
xblock_class
,
jsonfields
,
blocks
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
View file @
7e458582
...
...
@@ -251,6 +251,16 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli
course_key
=
self
.
_map_revision_to_branch
(
course_key
)
return
super
(
DraftVersioningModuleStore
,
self
)
.
get_orphans
(
course_key
,
**
kwargs
)
def
fix_not_found
(
self
,
course_key
,
user_id
):
"""
Fix any children which point to non-existent blocks in the course's published and draft branches
"""
for
branch
in
[
ModuleStoreEnum
.
RevisionOption
.
published_only
,
ModuleStoreEnum
.
RevisionOption
.
draft_only
]:
super
(
DraftVersioningModuleStore
,
self
)
.
fix_not_found
(
self
.
_map_revision_to_branch
(
course_key
,
branch
),
user_id
)
def
has_changes
(
self
,
xblock
):
"""
Checks if the given block has unpublished changes
...
...
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