Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cms/djangoapps/contentstore/tests/test_course_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ def test_course_update(self):
'provided_id': payload['id']})
content += '<div>div <p>p<br/></p></div>'
payload['content'] = content
# POST requests were coming in w/ these header values causing an error; so, repro error here
resp = self.client.post(first_update_url, json.dumps(payload),
"application/json")
"application/json",
HTTP_X_HTTP_METHOD_OVERRIDE="PUT",
REQUEST_METHOD="POST")

self.assertHTMLEqual(content, json.loads(resp.content)['content'],
"iframe w/ div")
Expand Down
5 changes: 3 additions & 2 deletions cms/djangoapps/contentstore/views/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.core.urlresolvers import reverse
from django.core.servers.basehttp import FileWrapper
from django.core.files.temp import NamedTemporaryFile
from django.views.decorators.http import require_POST
from django.views.decorators.http import require_POST, require_http_methods

from mitxmako.shortcuts import render_to_response
from cache_toolbox.core import del_cached_content
Expand Down Expand Up @@ -249,14 +249,15 @@ def remove_asset(request, org, course, name):


@ensure_csrf_cookie
@require_http_methods(("GET", "POST", "PUT"))
@login_required
def import_course(request, org, course, name):
"""
This method will handle a POST request to upload and import a .tar.gz file into a specified course
"""
location = get_location_and_verify_access(request, org, course, name)

if request.method == 'POST':
if request.method in ('POST', 'PUT'):
filename = request.FILES['course-data'].name

if not filename.endswith('.tar.gz'):
Expand Down
3 changes: 2 additions & 1 deletion cms/djangoapps/contentstore/views/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def edit_unit(request, location):

@expect_json
@login_required
@require_http_methods(("GET", "POST", "PUT"))
@ensure_csrf_cookie
def assignment_type_update(request, org, course, category, name):
'''
Expand All @@ -256,7 +257,7 @@ def assignment_type_update(request, org, course, category, name):

if request.method == 'GET':
return JsonResponse(CourseGradingModel.get_section_grader_type(location))
elif request.method == 'POST': # post or put, doesn't matter.
elif request.method in ('POST', 'PUT'): # post or put, doesn't matter.
return JsonResponse(CourseGradingModel.update_section_grader_type(location, request.POST))


Expand Down
12 changes: 6 additions & 6 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
ADVANCED_COMPONENT_POLICY_KEY)

from django_comment_common.utils import seed_permissions_roles
import datetime
from django.utils.timezone import UTC

from xmodule.html_module import AboutDescriptor
__all__ = ['course_index', 'create_new_course', 'course_info',
'course_info_updates', 'get_course_settings',
Expand Down Expand Up @@ -176,6 +175,7 @@ def course_info(request, org, course, name, provided_id=None):


@expect_json
@require_http_methods(("GET", "POST", "PUT", "DELETE"))
@login_required
@ensure_csrf_cookie
def course_info_updates(request, org, course, provided_id=None):
Expand Down Expand Up @@ -206,7 +206,7 @@ def course_info_updates(request, org, course, provided_id=None):
except:
return HttpResponseBadRequest("Failed to delete",
content_type="text/plain")
elif request.method == 'POST':
elif request.method in ('POST', 'PUT'): # can be either and sometimes django is rewriting one to the other
try:
return JsonResponse(update_course_updates(location, request.POST, provided_id))
except:
Expand Down Expand Up @@ -300,7 +300,7 @@ def course_settings_updates(request, org, course, name, section):
if request.method == 'GET':
# Cannot just do a get w/o knowing the course name :-(
return JsonResponse(manager.fetch(Location(['i4x', org, course, 'course', name])), encoder=CourseSettingsEncoder)
elif request.method == 'POST': # post or put, doesn't matter.
elif request.method in ('POST', 'PUT'): # post or put, doesn't matter.
return JsonResponse(manager.update_from_json(request.POST), encoder=CourseSettingsEncoder)


Expand Down Expand Up @@ -479,7 +479,7 @@ def textbook_index(request, org, course, name):
if request.is_ajax():
if request.method == 'GET':
return JsonResponse(course_module.pdf_textbooks)
elif request.method == 'POST':
elif request.method in ('POST', 'PUT'): # can be either and sometimes django is rewriting one to the other
try:
textbooks = validate_textbooks_json(request.body)
except TextbookValidationError as err:
Expand Down Expand Up @@ -580,7 +580,7 @@ def textbook_by_id(request, org, course, name, tid):
if not textbook:
return JsonResponse(status=404)
return JsonResponse(textbook)
elif request.method in ('POST', 'PUT'):
elif request.method in ('POST', 'PUT'): # can be either and sometimes django is rewriting one to the other
try:
new_textbook = validate_textbook_json(request.body)
except TextbookValidationError as err:
Expand Down