Revert "SUST-35 Implementation of course_key_from_string_or_404 to return course_key or raise a 404"
This commit is contained in:
committed by
Clinton Blackburn
parent
872d225921
commit
c601e9fc48
@@ -91,7 +91,7 @@ from util.organizations_helpers import (
|
||||
organizations_enabled,
|
||||
)
|
||||
from util.string_utils import _has_non_ascii_characters
|
||||
from util.course_key_utils import course_key_from_string_or_404
|
||||
from util.course_key_utils import from_string_or_404
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
from xmodule.course_module import CourseFields
|
||||
from xmodule.course_module import DEFAULT_START_DATE
|
||||
@@ -875,7 +875,7 @@ def course_info_handler(request, course_key_string):
|
||||
GET
|
||||
html: return html for editing the course info handouts and updates.
|
||||
"""
|
||||
course_key = course_key_from_string_or_404(course_key_string)
|
||||
course_key = from_string_or_404(course_key_string)
|
||||
|
||||
with modulestore().bulk_operations(course_key):
|
||||
course_module = get_course_and_check_access(course_key, request.user)
|
||||
|
||||
@@ -14,8 +14,7 @@ from edxmako.shortcuts import render_to_response
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.tabs import CourseTabList, CourseTab, InvalidTabsException, StaticTab
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
from util.course_key_utils import course_key_from_string_or_404
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey
|
||||
|
||||
from ..utils import get_lms_link_for_item
|
||||
|
||||
@@ -40,7 +39,7 @@ def tabs_handler(request, course_key_string):
|
||||
Creating a tab, deleting a tab, or changing its contents is not supported through this method.
|
||||
Instead use the general xblock URL (see item.xblock_handler).
|
||||
"""
|
||||
course_key = course_key_from_string_or_404(course_key_string)
|
||||
course_key = CourseKey.from_string(course_key_string)
|
||||
if not has_course_author_access(request.user, course_key):
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
@@ -7,12 +7,9 @@ from contentstore.tests.utils import CourseTestCase
|
||||
from contentstore.utils import reverse_course_url
|
||||
from xmodule.x_module import STUDENT_VIEW
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from django.test.client import RequestFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.tabs import CourseTabList
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from django.http import Http404
|
||||
from contentstore.views.tabs import tabs_handler
|
||||
|
||||
|
||||
class TabsPageTests(CourseTestCase):
|
||||
@@ -194,14 +191,6 @@ class TabsPageTests(CourseTestCase):
|
||||
self.assertIn('<span class="sr">Delete this component</span>', html)
|
||||
self.assertIn('<span data-tooltip="Drag to reorder" class="drag-handle action"></span>', html)
|
||||
|
||||
def test_invalid_course_id(self):
|
||||
""" Asserts that Http404 is raised when the course id is not valid. """
|
||||
request_factory = RequestFactory()
|
||||
request = request_factory.get('/dummy-url')
|
||||
request.user = self.user
|
||||
with self.assertRaises(Http404):
|
||||
tabs_handler(request, "/some.invalid.key/course-v1:TTT+CS01+2015_T0")
|
||||
|
||||
|
||||
class PrimitiveTabEdit(ModuleStoreTestCase):
|
||||
"""Tests for the primitive tab edit data manipulations"""
|
||||
|
||||
@@ -9,9 +9,6 @@ from django.contrib.auth.models import User
|
||||
from student.models import CourseEnrollment
|
||||
from student.roles import CourseStaffRole, CourseInstructorRole
|
||||
from student import auth
|
||||
from django.http import Http404
|
||||
from contentstore.views.user import course_team_handler
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
|
||||
class UsersTestCase(CourseTestCase):
|
||||
@@ -318,11 +315,3 @@ class UsersTestCase(CourseTestCase):
|
||||
CourseEnrollment.is_enrolled(self.ext_user, self.course.id),
|
||||
'User ext_user should have been enrolled in the course'
|
||||
)
|
||||
|
||||
def test_invalid_course_id(self):
|
||||
""" Asserts that Http404 is raised when the course id is not valid. """
|
||||
request_factory = RequestFactory()
|
||||
request = request_factory.get('/dummy-url')
|
||||
request.user = self.user
|
||||
with self.assertRaises(Http404):
|
||||
course_team_handler(request, "/some.invalid.key/course-v1:TTT+CS01+2015_T0")
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from edxmako.shortcuts import render_to_response
|
||||
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from util.course_key_utils import course_key_from_string_or_404
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
from util.json_request import JsonResponse, expect_json
|
||||
from student.roles import CourseInstructorRole, CourseStaffRole, LibraryUserRole
|
||||
@@ -49,7 +49,7 @@ def course_team_handler(request, course_key_string=None, email=None):
|
||||
DELETE:
|
||||
json: remove a particular course team member from the course team (email is required).
|
||||
"""
|
||||
course_key = course_key_from_string_or_404(course_key_string) if course_key_string else None
|
||||
course_key = CourseKey.from_string(course_key_string) if course_key_string else None
|
||||
# No permissions check here - each helper method does its own check.
|
||||
|
||||
if 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json'):
|
||||
|
||||
Reference in New Issue
Block a user