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
4896444d
Commit
4896444d
authored
Aug 02, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up item views, use JsonResponse class
parent
ece4ec3f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
cms/djangoapps/contentstore/views/item.py
+11
-8
No files found.
cms/djangoapps/contentstore/views/item.py
View file @
4896444d
import
json
from
uuid
import
uuid4
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
HttpResponse
from
django.contrib.auth.decorators
import
login_required
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.inheritance
import
own_metadata
from
util.json_request
import
expect_json
from
util.json_request
import
expect_json
,
JsonResponse
from
..utils
import
get_modulestore
from
.access
import
has_access
from
.requests
import
_xmodule_recurse
...
...
@@ -20,6 +18,7 @@ __all__ = ['save_item', 'create_item', 'delete_item']
# cdodge: these are categories which should not be parented, they are detached from the hierarchy
DETACHED_CATEGORIES
=
[
'about'
,
'static_tab'
,
'course_info'
]
@login_required
@expect_json
def
save_item
(
request
):
...
...
@@ -80,7 +79,7 @@ def save_item(request):
# commit to datastore
store
.
update_metadata
(
item_location
,
own_metadata
(
existing_item
))
return
Http
Response
()
return
Json
Response
()
# [DHM] A hack until we implement a permanent soln. Proposed perm solution is to make namespace fields also top level
...
...
@@ -139,13 +138,17 @@ def create_item(request):
if
display_name
is
not
None
:
metadata
[
'display_name'
]
=
display_name
get_modulestore
(
category
)
.
create_and_save_xmodule
(
dest_location
,
definition_data
=
data
,
metadata
=
metadata
,
system
=
parent
.
system
)
get_modulestore
(
category
)
.
create_and_save_xmodule
(
dest_location
,
definition_data
=
data
,
metadata
=
metadata
,
system
=
parent
.
system
,
)
if
category
not
in
DETACHED_CATEGORIES
:
get_modulestore
(
parent
.
location
)
.
update_children
(
parent_location
,
parent
.
children
+
[
dest_location
.
url
()])
return
HttpResponse
(
json
.
dumps
({
'id'
:
dest_location
.
url
()})
)
return
JsonResponse
({
'id'
:
dest_location
.
url
()}
)
@login_required
...
...
@@ -184,4 +187,4 @@ def delete_item(request):
parent
.
children
=
children
modulestore
(
'direct'
)
.
update_children
(
parent
.
location
,
parent
.
children
)
return
Http
Response
()
return
Json
Response
()
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