Commit 4c15dd93 by attiyaishaque

Course export page will not be opened for course id that does not belong to any course.

parent 069e884f
...@@ -16,7 +16,7 @@ from django.contrib.auth.decorators import login_required ...@@ -16,7 +16,7 @@ from django.contrib.auth.decorators import login_required
from django.core.exceptions import SuspiciousOperation, PermissionDenied from django.core.exceptions import SuspiciousOperation, PermissionDenied
from django.core.files.temp import NamedTemporaryFile from django.core.files.temp import NamedTemporaryFile
from django.core.servers.basehttp import FileWrapper 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.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods, require_GET from django.views.decorators.http import require_http_methods, require_GET
...@@ -489,6 +489,8 @@ def export_handler(request, course_key_string): ...@@ -489,6 +489,8 @@ def export_handler(request, course_key_string):
} }
else: else:
courselike_module = modulestore().get_course(course_key) courselike_module = modulestore().get_course(course_key)
if courselike_module is None:
raise Http404
context = { context = {
'context_course': courselike_module, 'context_course': courselike_module,
'courselike_home_url': reverse_course_url("course_handler", course_key), 'courselike_home_url': reverse_course_url("course_handler", course_key),
......
...@@ -510,6 +510,7 @@ class ImportTestCase(CourseTestCase): ...@@ -510,6 +510,7 @@ class ImportTestCase(CourseTestCase):
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
@ddt.ddt
class ExportTestCase(CourseTestCase): class ExportTestCase(CourseTestCase):
""" """
Tests for export_handler. Tests for export_handler.
...@@ -630,6 +631,17 @@ class ExportTestCase(CourseTestCase): ...@@ -630,6 +631,17 @@ class ExportTestCase(CourseTestCase):
self.test_export_targz_urlparam() 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) @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
class TestLibraryImportExport(CourseTestCase): class TestLibraryImportExport(CourseTestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment