Merge pull request #12133 from edx/atiya/TNL-4376-course-export-page
Course export page will not be opened for course id that does not bel…
This commit is contained in:
@@ -16,7 +16,7 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.core.exceptions import SuspiciousOperation, PermissionDenied
|
||||
from django.core.files.temp import NamedTemporaryFile
|
||||
from django.core.servers.basehttp import FileWrapper
|
||||
from django.http import HttpResponse, HttpResponseNotFound
|
||||
from django.http import HttpResponse, HttpResponseNotFound, Http404
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.decorators.http import require_http_methods, require_GET
|
||||
@@ -489,6 +489,8 @@ def export_handler(request, course_key_string):
|
||||
}
|
||||
else:
|
||||
courselike_module = modulestore().get_course(course_key)
|
||||
if courselike_module is None:
|
||||
raise Http404
|
||||
context = {
|
||||
'context_course': courselike_module,
|
||||
'courselike_home_url': reverse_course_url("course_handler", course_key),
|
||||
|
||||
@@ -510,6 +510,7 @@ class ImportTestCase(CourseTestCase):
|
||||
|
||||
|
||||
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
|
||||
@ddt.ddt
|
||||
class ExportTestCase(CourseTestCase):
|
||||
"""
|
||||
Tests for export_handler.
|
||||
@@ -630,6 +631,17 @@ class ExportTestCase(CourseTestCase):
|
||||
|
||||
self.test_export_targz_urlparam()
|
||||
|
||||
@ddt.data(
|
||||
'/export/non.1/existence_1/Run_1', # For mongo
|
||||
'/export/course-v1:non1+existence1+Run1', # For split
|
||||
)
|
||||
def test_export_course_doest_not_exist(self, url):
|
||||
"""
|
||||
Export failure if course is not exist
|
||||
"""
|
||||
resp = self.client.get_html(url)
|
||||
self.assertEquals(resp.status_code, 404)
|
||||
|
||||
|
||||
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
|
||||
class TestLibraryImportExport(CourseTestCase):
|
||||
|
||||
Reference in New Issue
Block a user