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
3c8de11f
Commit
3c8de11f
authored
Oct 12, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standardize on how we bypass the draft-aware modulestore
parent
281f194b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
cms/djangoapps/contentstore/views.py
+19
-18
No files found.
cms/djangoapps/contentstore/views.py
View file @
3c8de11f
...
@@ -57,6 +57,18 @@ log = logging.getLogger(__name__)
...
@@ -57,6 +57,18 @@ log = logging.getLogger(__name__)
COMPONENT_TYPES
=
[
'customtag'
,
'discussion'
,
'html'
,
'problem'
,
'video'
]
COMPONENT_TYPES
=
[
'customtag'
,
'discussion'
,
'html'
,
'problem'
,
'video'
]
DIRECT_ONLY_CATEGORIES
=
[
'course'
,
'chapter'
,
'sequential'
]
def
_modulestore
(
location
):
"""
Returns the correct modulestore to use for modifying the specified location
"""
if
location
.
category
in
DIRECT_ONLY_CATEGORIES
:
return
modulestore
(
'direct'
)
else
:
return
modulestore
()
# ==== Public views ==================================================
# ==== Public views ==================================================
...
@@ -470,16 +482,13 @@ def delete_item(request):
...
@@ -470,16 +482,13 @@ def delete_item(request):
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
modulestore
()
.
get_item
(
item_location
)
_direct_delete_categories
=
[
'course'
,
'chapter'
,
'sequential'
]
# @TODO: this probably leaves draft items dangling.
# @TODO: this probably leaves draft items dangling.
if
delete_children
:
if
delete_children
:
_xmodule_recurse
(
item
,
lambda
i
:
modulestore
(
'direct'
if
_xmodule_recurse
(
item
,
lambda
i
:
_modulestore
(
i
.
location
)
.
delete_item
(
i
.
location
))
i
.
location
.
category
in
_direct_delete_categories
else
'direct'
)
.
delete_item
(
i
.
location
))
else
:
else
:
modulestore
(
'direct'
if
_modulestore
(
item
.
location
)
.
delete_item
(
item
.
location
)
item
.
location
.
category
in
_direct_delete_categories
else
'direct'
)
.
delete_item
(
item
.
location
)
return
HttpResponse
()
return
HttpResponse
()
...
@@ -591,28 +600,20 @@ def clone_item(request):
...
@@ -591,28 +600,20 @@ def clone_item(request):
if
not
has_access
(
request
.
user
,
parent_location
):
if
not
has_access
(
request
.
user
,
parent_location
):
raise
PermissionDenied
()
raise
PermissionDenied
()
# if we are creating a new section or subsection, then we don't want draft awareness
parent
=
_modulestore
(
template
)
.
get_item
(
parent_location
)
_modulestore
=
modulestore
()
if
template
.
category
not
in
(
'sequential'
,
'chapter'
)
else
modulestore
(
'direct'
)
parent
=
_modulestore
.
get_item
(
parent_location
)
dest_location
=
parent_location
.
_replace
(
category
=
template
.
category
,
name
=
uuid4
()
.
hex
)
dest_location
=
parent_location
.
_replace
(
category
=
template
.
category
,
name
=
uuid4
()
.
hex
)
new_item
=
_modulestore
.
clone_item
(
template
,
dest_location
)
new_item
=
_modulestore
(
template
)
.
clone_item
(
template
,
dest_location
)
# TODO: This needs to be deleted when we have proper storage for static content
# TODO: This needs to be deleted when we have proper storage for static content
new_item
.
metadata
[
'data_dir'
]
=
parent
.
metadata
[
'data_dir'
]
new_item
.
metadata
[
'data_dir'
]
=
parent
.
metadata
[
'data_dir'
]
# replace the display name with an optional parameter passed in from the caller
# replace the display name with an optional parameter passed in from the caller
if
display_name
is
not
None
:
if
display_name
is
not
None
:
new_item
.
metadata
[
'display_name'
]
=
display_name
new_item
.
metadata
[
'display_name'
]
=
display_name
_modulestore
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
_modulestore
(
template
)
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
_modulestore
(
parent
.
location
)
.
update_children
(
parent_location
,
parent
.
definition
.
get
(
'children'
,
[])
+
[
new_item
.
location
.
url
()])
if
parent_location
.
category
not
in
(
'vertical'
,):
parent_update_modulestore
=
modulestore
(
'direct'
)
else
:
parent_update_modulestore
=
modulestore
()
parent_update_modulestore
.
update_children
(
parent_location
,
parent
.
definition
.
get
(
'children'
,
[])
+
[
new_item
.
location
.
url
()])
return
HttpResponse
(
json
.
dumps
({
'id'
:
dest_location
.
url
()}))
return
HttpResponse
(
json
.
dumps
({
'id'
:
dest_location
.
url
()}))
...
...
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