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
6b3b7fe2
Commit
6b3b7fe2
authored
Mar 21, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cleanup.
parent
0a063342
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
28 deletions
+22
-28
cms/djangoapps/contentstore/features/checklists.feature
+2
-2
cms/djangoapps/contentstore/views.py
+20
-26
No files found.
cms/djangoapps/contentstore/features/checklists.feature
View file @
6b3b7fe2
...
...
@@ -18,4 +18,5 @@ Feature: Course checklists
Scenario
:
A
task can link to a location outside Studio
Given
I have opened Checklists
When
I select a link to help page
Then
I am brought to the help page in a new window
\ No newline at end of file
Then
I am brought to the help page in a new window
cms/djangoapps/contentstore/views.py
View file @
6b3b7fe2
...
...
@@ -791,9 +791,7 @@ def upload_asset(request, org, course, coursename):
return
HttpResponseBadRequest
()
# construct a location from the passed in path
location
=
[
'i4x'
,
org
,
course
,
'course'
,
coursename
]
if
not
has_access
(
request
.
user
,
location
):
return
HttpResponseForbidden
()
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
coursename
)
# Does the course actually exist?!? Get anything from it to prove its existance
...
...
@@ -945,11 +943,7 @@ def landing(request, org, course, coursename):
@ensure_csrf_cookie
def
static_pages
(
request
,
org
,
course
,
coursename
):
location
=
[
'i4x'
,
org
,
course
,
'course'
,
coursename
]
# check that logged in user has permissions to this item
if
not
has_access
(
request
.
user
,
location
):
raise
PermissionDenied
()
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
coursename
)
course
=
modulestore
()
.
get_item
(
location
)
...
...
@@ -1221,11 +1215,7 @@ def course_settings_updates(request, org, course, name, section):
org, course: Attributes of the Location for the item to edit
section: one of details, faculty, grading, problems, discussions
"""
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
# check that logged in user has permissions to this item
if
not
has_access
(
request
.
user
,
location
):
raise
PermissionDenied
()
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
if
section
==
'details'
:
manager
=
CourseDetails
...
...
@@ -1293,7 +1283,7 @@ def course_advanced_updates(request, org, course, name):
return
HttpResponse
(
json
.
dumps
(
CourseMetadata
.
update_from_json
(
location
,
json
.
loads
(
request
.
body
))),
mimetype
=
"application/json"
)
#@ensure_csrf_cookie what is this cookie?
@ensure_csrf_cookie
@login_required
def
get_checklists
(
request
,
org
,
course
,
name
):
"""
...
...
@@ -1313,8 +1303,7 @@ def get_checklists(request, org, course, name):
course_module
.
checklists
=
template_module
.
checklists
modulestore
.
update_metadata
(
location
,
own_metadata
(
course_module
))
checklists
=
course_module
.
checklists
create_checklist_action_urls
(
checklists
,
course_module
)
checklists
=
get_checklists_with_action_urls
(
course_module
)
return
render_to_response
(
'checklists.html'
,
{
'context_course'
:
course_module
,
...
...
@@ -1322,6 +1311,7 @@ def get_checklists(request, org, course, name):
})
@ensure_csrf_cookie
@login_required
def
update_checklist
(
request
,
org
,
course
,
name
,
checklist_index
=
None
):
"""
...
...
@@ -1343,24 +1333,31 @@ def update_checklist(request, org, course, name, checklist_index=None):
modified_checklist
=
json
.
loads
(
request
.
body
)
course_module
.
checklists
[
int
(
checklist_index
)]
=
modified_checklist
modulestore
.
update_metadata
(
location
,
own_metadata
(
course_module
))
c
reate_checklist_action_urls
([
modified_checklist
],
course_module
)
return
HttpResponse
(
json
.
dumps
(
modified_checklist
),
mimetype
=
"application/json"
)
c
hecklists
=
get_checklists_with_action_urls
(
course_module
)
return
HttpResponse
(
json
.
dumps
(
checklists
),
mimetype
=
"application/json"
)
else
:
return
HttpResponseBadRequest
(
"Could not save checklist state because the checklist index was out of range or unspecified."
,
content_type
=
"text/plain"
)
elif
request
.
method
==
'GET'
:
# In the JavaScript view initialize method, we do a fetch to get all the checklists.
checklists
=
course_module
.
checklists
create_checklist_action_urls
(
checklists
,
course_module
)
checklists
=
get_checklists_with_action_urls
(
course_module
)
return
HttpResponse
(
json
.
dumps
(
checklists
),
mimetype
=
"application/json"
)
def
create_checklist_action_urls
(
checklists
,
course_module
):
def
get_checklists_with_action_urls
(
course_module
):
"""
Gets the checklists out of the course module and expands their action urls.
Returns the checklists with modified urls (different from what is stored in the course moduule).
"""
checklists
=
course_module
.
checklists
# Expand action names to their URLs.
for
checklist
in
checklists
:
for
item
in
checklist
.
get
(
'items'
):
item
[
'action_url'
]
=
get_url_reverse
(
item
.
get
(
'action_url'
),
course_module
)
return
checklists
@login_required
@ensure_csrf_cookie
def
asset_index
(
request
,
org
,
course
,
name
):
...
...
@@ -1597,9 +1594,6 @@ def export_course(request, org, course, name):
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
course_module
=
modulestore
()
.
get_item
(
location
)
# check that logged in user has permissions to this item
if
not
has_access
(
request
.
user
,
location
):
raise
PermissionDenied
()
return
render_to_response
(
'export.html'
,
{
'context_course'
:
course_module
,
...
...
@@ -1627,7 +1621,7 @@ def render_500(request):
def
get_location_and_verify_access
(
request
,
org
,
course
,
name
):
"""
Create the location tuple verify that the user has permissions
to view the location.
to view the location.
Returns the location.
"""
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
...
...
@@ -1641,7 +1635,7 @@ def get_location_and_verify_access(request, org, course, name):
def
get_request_method
(
request
):
"""
Using HTTP_X_HTTP_METHOD_OVERRIDE, in the request metadata, determine
what type of request came from the client.
what type of request came from the client
, and return it
.
"""
# NB: we're setting Backbone.emulateHTTP to true on the client so everything comes as a post!!!
if
request
.
method
==
'POST'
and
'HTTP_X_HTTP_METHOD_OVERRIDE'
in
request
.
META
:
...
...
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