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
...
@@ -18,4 +18,5 @@ Feature: Course checklists
Scenario
:
A
task can link to a location outside Studio
Scenario
:
A
task can link to a location outside Studio
Given
I have opened Checklists
Given
I have opened Checklists
When
I select a link to help page
When
I select a link to help page
Then
I am brought to the help page in a new window
Then
I am brought to the help page in a new window
\ No newline at end of file
cms/djangoapps/contentstore/views.py
View file @
6b3b7fe2
...
@@ -791,9 +791,7 @@ def upload_asset(request, org, course, coursename):
...
@@ -791,9 +791,7 @@ def upload_asset(request, org, course, coursename):
return
HttpResponseBadRequest
()
return
HttpResponseBadRequest
()
# construct a location from the passed in path
# construct a location from the passed in path
location
=
[
'i4x'
,
org
,
course
,
'course'
,
coursename
]
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
coursename
)
if
not
has_access
(
request
.
user
,
location
):
return
HttpResponseForbidden
()
# Does the course actually exist?!? Get anything from it to prove its existance
# Does the course actually exist?!? Get anything from it to prove its existance
...
@@ -945,11 +943,7 @@ def landing(request, org, course, coursename):
...
@@ -945,11 +943,7 @@ def landing(request, org, course, coursename):
@ensure_csrf_cookie
@ensure_csrf_cookie
def
static_pages
(
request
,
org
,
course
,
coursename
):
def
static_pages
(
request
,
org
,
course
,
coursename
):
location
=
[
'i4x'
,
org
,
course
,
'course'
,
coursename
]
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
coursename
)
# check that logged in user has permissions to this item
if
not
has_access
(
request
.
user
,
location
):
raise
PermissionDenied
()
course
=
modulestore
()
.
get_item
(
location
)
course
=
modulestore
()
.
get_item
(
location
)
...
@@ -1221,11 +1215,7 @@ def course_settings_updates(request, org, course, name, section):
...
@@ -1221,11 +1215,7 @@ def course_settings_updates(request, org, course, name, section):
org, course: Attributes of the Location for the item to edit
org, course: Attributes of the Location for the item to edit
section: one of details, faculty, grading, problems, discussions
section: one of details, faculty, grading, problems, discussions
"""
"""
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
# check that logged in user has permissions to this item
if
not
has_access
(
request
.
user
,
location
):
raise
PermissionDenied
()
if
section
==
'details'
:
if
section
==
'details'
:
manager
=
CourseDetails
manager
=
CourseDetails
...
@@ -1293,7 +1283,7 @@ def course_advanced_updates(request, org, course, name):
...
@@ -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"
)
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
@login_required
def
get_checklists
(
request
,
org
,
course
,
name
):
def
get_checklists
(
request
,
org
,
course
,
name
):
"""
"""
...
@@ -1313,8 +1303,7 @@ def get_checklists(request, org, course, name):
...
@@ -1313,8 +1303,7 @@ def get_checklists(request, org, course, name):
course_module
.
checklists
=
template_module
.
checklists
course_module
.
checklists
=
template_module
.
checklists
modulestore
.
update_metadata
(
location
,
own_metadata
(
course_module
))
modulestore
.
update_metadata
(
location
,
own_metadata
(
course_module
))
checklists
=
course_module
.
checklists
checklists
=
get_checklists_with_action_urls
(
course_module
)
create_checklist_action_urls
(
checklists
,
course_module
)
return
render_to_response
(
'checklists.html'
,
return
render_to_response
(
'checklists.html'
,
{
{
'context_course'
:
course_module
,
'context_course'
:
course_module
,
...
@@ -1322,6 +1311,7 @@ def get_checklists(request, org, course, name):
...
@@ -1322,6 +1311,7 @@ def get_checklists(request, org, course, name):
})
})
@ensure_csrf_cookie
@login_required
@login_required
def
update_checklist
(
request
,
org
,
course
,
name
,
checklist_index
=
None
):
def
update_checklist
(
request
,
org
,
course
,
name
,
checklist_index
=
None
):
"""
"""
...
@@ -1343,24 +1333,31 @@ 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
)
modified_checklist
=
json
.
loads
(
request
.
body
)
course_module
.
checklists
[
int
(
checklist_index
)]
=
modified_checklist
course_module
.
checklists
[
int
(
checklist_index
)]
=
modified_checklist
modulestore
.
update_metadata
(
location
,
own_metadata
(
course_module
))
modulestore
.
update_metadata
(
location
,
own_metadata
(
course_module
))
c
reate_checklist_action_urls
([
modified_checklist
],
course_module
)
c
hecklists
=
get_checklists_with_action_urls
(
course_module
)
return
HttpResponse
(
json
.
dumps
(
modified_checklist
),
mimetype
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
checklists
),
mimetype
=
"application/json"
)
else
:
else
:
return
HttpResponseBadRequest
(
"Could not save checklist state because the checklist index was out of range or unspecified."
,
return
HttpResponseBadRequest
(
"Could not save checklist state because the checklist index was out of range or unspecified."
,
content_type
=
"text/plain"
)
content_type
=
"text/plain"
)
elif
request
.
method
==
'GET'
:
elif
request
.
method
==
'GET'
:
# In the JavaScript view initialize method, we do a fetch to get all the checklists.
# In the JavaScript view initialize method, we do a fetch to get all the checklists.
checklists
=
course_module
.
checklists
checklists
=
get_checklists_with_action_urls
(
course_module
)
create_checklist_action_urls
(
checklists
,
course_module
)
return
HttpResponse
(
json
.
dumps
(
checklists
),
mimetype
=
"application/json"
)
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.
# Expand action names to their URLs.
for
checklist
in
checklists
:
for
checklist
in
checklists
:
for
item
in
checklist
.
get
(
'items'
):
for
item
in
checklist
.
get
(
'items'
):
item
[
'action_url'
]
=
get_url_reverse
(
item
.
get
(
'action_url'
),
course_module
)
item
[
'action_url'
]
=
get_url_reverse
(
item
.
get
(
'action_url'
),
course_module
)
return
checklists
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
asset_index
(
request
,
org
,
course
,
name
):
def
asset_index
(
request
,
org
,
course
,
name
):
...
@@ -1597,9 +1594,6 @@ def export_course(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
)
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
course_module
=
modulestore
()
.
get_item
(
location
)
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'
,
{
return
render_to_response
(
'export.html'
,
{
'context_course'
:
course_module
,
'context_course'
:
course_module
,
...
@@ -1627,7 +1621,7 @@ def render_500(request):
...
@@ -1627,7 +1621,7 @@ def render_500(request):
def
get_location_and_verify_access
(
request
,
org
,
course
,
name
):
def
get_location_and_verify_access
(
request
,
org
,
course
,
name
):
"""
"""
Create the location tuple verify that the user has permissions
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
]
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
...
@@ -1641,7 +1635,7 @@ def get_location_and_verify_access(request, org, course, name):
...
@@ -1641,7 +1635,7 @@ def get_location_and_verify_access(request, org, course, name):
def
get_request_method
(
request
):
def
get_request_method
(
request
):
"""
"""
Using HTTP_X_HTTP_METHOD_OVERRIDE, in the request metadata, determine
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!!!
# 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
:
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