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
83db659f
Commit
83db659f
authored
May 19, 2014
by
zubair-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create draft request gets already created version if it exists
STUD-1616
parent
b7816aaf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
cms/djangoapps/contentstore/views/item.py
+6
-2
cms/djangoapps/contentstore/views/tests/test_item.py
+33
-0
No files found.
cms/djangoapps/contentstore/views/item.py
View file @
83db659f
...
...
@@ -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
...
...
@@ -314,7 +314,11 @@ def _save_item(request, usage_loc, item_location, data=None, children=None, meta
elif
publish
==
'create_draft'
:
# This recursively clones the existing item location to a draft location (the draft is
# implicit, because modulestore is a Draft modulestore)
_xmodule_recurse
(
existing_item
,
lambda
i
:
modulestore
()
.
convert_to_draft
(
i
.
location
))
try
:
_xmodule_recurse
(
existing_item
,
lambda
i
:
modulestore
()
.
convert_to_draft
(
i
.
location
))
except
DuplicateItemError
:
# Since there is already a draft version of this module so no need to create another
pass
if
data
:
# TODO Allow any scope.content fields not just "data" (exactly like the get below this)
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
83db659f
...
...
@@ -632,6 +632,39 @@ class TestEditItem(ItemTest):
draft
=
self
.
get_item_from_modulestore
(
self
.
problem_locator
,
True
)
self
.
assertEqual
(
draft
.
due
,
datetime
(
2077
,
10
,
10
,
4
,
0
,
tzinfo
=
UTC
))
def
test_create_draft_with_multiple_requests
(
self
):
"""
Create a draft request returns already created version if it exists.
"""
# Make problem public.
self
.
client
.
ajax_post
(
self
.
problem_update_url
,
data
=
{
'publish'
:
'make_public'
}
)
self
.
assertIsNotNone
(
self
.
get_item_from_modulestore
(
self
.
problem_locator
,
False
))
# Now make it draft, which means both versions will exist.
self
.
client
.
ajax_post
(
self
.
problem_update_url
,
data
=
{
'publish'
:
'create_draft'
}
)
self
.
assertIsNotNone
(
self
.
get_item_from_modulestore
(
self
.
problem_locator
,
False
))
draft_1
=
self
.
get_item_from_modulestore
(
self
.
problem_locator
,
True
)
self
.
assertIsNotNone
(
draft_1
)
# Now check that when a user sends request to create a draft when there is already a draft version then
# user gets that already created draft instead of getting DuplicateItemError exception.
self
.
client
.
ajax_post
(
self
.
problem_update_url
,
data
=
{
'publish'
:
'create_draft'
}
)
draft_2
=
self
.
get_item_from_modulestore
(
self
.
problem_locator
,
True
)
self
.
assertIsNotNone
(
draft_2
)
self
.
assertEqual
(
draft_1
,
draft_2
)
def
test_published_and_draft_contents_with_update
(
self
):
""" Create a draft and publish it then modify the draft and check that published content is not modified """
...
...
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