Merge pull request #2022 from edx/dhm/locator_course_id
Change course_id to package_id
This commit is contained in:
@@ -37,23 +37,21 @@ def get_all_course_role_groupnames(location, role, use_filter=True):
|
||||
'''
|
||||
location = Locator.to_locator_or_location(location)
|
||||
|
||||
# hack: check for existence of a group name in the legacy LMS format <role>_<course>
|
||||
# if it exists, then use that one, otherwise use a <role>_<course_id> which contains
|
||||
# more information
|
||||
groupnames = []
|
||||
try:
|
||||
groupnames.append('{0}_{1}'.format(role, location.course_id))
|
||||
except InvalidLocationError: # will occur on old locations where location is not of category course
|
||||
pass
|
||||
if isinstance(location, Location):
|
||||
# least preferred role_course format
|
||||
groupnames.append('{0}_{1}'.format(role, location.course))
|
||||
try:
|
||||
groupnames.append('{0}_{1}'.format(role, location.course_id))
|
||||
except InvalidLocationError: # will occur on old locations where location is not of category course
|
||||
pass
|
||||
try:
|
||||
locator = loc_mapper().translate_location(location.course_id, location, False, False)
|
||||
groupnames.append('{0}_{1}'.format(role, locator.course_id))
|
||||
groupnames.append('{0}_{1}'.format(role, locator.package_id))
|
||||
except (InvalidLocationError, ItemNotFoundError):
|
||||
pass
|
||||
# least preferred role_course format for legacy reasons
|
||||
groupnames.append('{0}_{1}'.format(role, location.course))
|
||||
elif isinstance(location, CourseLocator):
|
||||
groupnames.append('{0}_{1}'.format(role, location.package_id))
|
||||
old_location = loc_mapper().translate_locator_to_location(location, get_course=True)
|
||||
if old_location:
|
||||
# the slashified version of the course_id (myu/mycourse/myrun)
|
||||
|
||||
@@ -136,13 +136,13 @@ class TemplateTests(unittest.TestCase):
|
||||
persistent_factories.ItemFactory.create(display_name='chapter 1',
|
||||
parent_location=test_course.location)
|
||||
|
||||
id_locator = CourseLocator(course_id=test_course.location.course_id, branch='draft')
|
||||
id_locator = CourseLocator(package_id=test_course.location.package_id, branch='draft')
|
||||
guid_locator = CourseLocator(version_guid=test_course.location.version_guid)
|
||||
# verify it can be retireved by id
|
||||
self.assertIsInstance(modulestore('split').get_course(id_locator), CourseDescriptor)
|
||||
# and by guid
|
||||
self.assertIsInstance(modulestore('split').get_course(guid_locator), CourseDescriptor)
|
||||
modulestore('split').delete_course(id_locator.course_id)
|
||||
modulestore('split').delete_course(id_locator.package_id)
|
||||
# test can no longer retrieve by id
|
||||
self.assertRaises(ItemNotFoundError, modulestore('split').get_course, id_locator)
|
||||
# but can by guid
|
||||
|
||||
@@ -90,7 +90,7 @@ class TestCourseAccess(ModuleStoreTestCase):
|
||||
# first check the groupname for the course creator.
|
||||
self.assertTrue(
|
||||
self.user.groups.filter(
|
||||
name="{}_{}".format(INSTRUCTOR_ROLE_NAME, self.course_locator.course_id)
|
||||
name="{}_{}".format(INSTRUCTOR_ROLE_NAME, self.course_locator.package_id)
|
||||
).exists(),
|
||||
"Didn't add creator as instructor."
|
||||
)
|
||||
@@ -124,4 +124,4 @@ class TestCourseAccess(ModuleStoreTestCase):
|
||||
for role in [INSTRUCTOR_ROLE_NAME, STAFF_ROLE_NAME]:
|
||||
for user in user_by_role[role]:
|
||||
self.assertTrue(has_access(user, copy_course_locator), "{} no copy access".format(user))
|
||||
self.assertTrue(has_access(user, copy_course_location), "{} no copy access".format(user))
|
||||
self.assertTrue(has_access(user, copy_course_location), "{} no copy access".format(user))
|
||||
|
||||
@@ -34,7 +34,7 @@ __all__ = ['assets_handler']
|
||||
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
def assets_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None, asset_id=None):
|
||||
def assets_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None, asset_id=None):
|
||||
"""
|
||||
The restful handler for assets.
|
||||
It allows retrieval of all the assets (as an HTML page), as well as uploading new assets,
|
||||
@@ -51,7 +51,7 @@ def assets_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
DELETE
|
||||
json: delete an asset
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, location):
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ __all__ = ['checklists_handler']
|
||||
@require_http_methods(("GET", "POST", "PUT"))
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
def checklists_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None, checklist_index=None):
|
||||
def checklists_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None, checklist_index=None):
|
||||
"""
|
||||
The restful handler for checklists.
|
||||
|
||||
@@ -36,7 +36,7 @@ def checklists_handler(request, tag=None, course_id=None, branch=None, version_g
|
||||
POST or PUT
|
||||
json: updates the checked state for items within a particular checklist. checklist_index is required.
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, location):
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules'
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@login_required
|
||||
def subsection_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def subsection_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for subsection-specific requests.
|
||||
|
||||
@@ -65,7 +65,7 @@ def subsection_handler(request, tag=None, course_id=None, branch=None, version_g
|
||||
json: not currently supported
|
||||
"""
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):
|
||||
locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
locator = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
try:
|
||||
old_location, course, item, lms_link = _get_item_in_course(request, locator)
|
||||
except ItemNotFoundError:
|
||||
@@ -145,7 +145,7 @@ def _load_mixed_class(category):
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@login_required
|
||||
def unit_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def unit_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for unit-specific requests.
|
||||
|
||||
@@ -154,7 +154,7 @@ def unit_handler(request, tag=None, course_id=None, branch=None, version_guid=No
|
||||
json: not currently supported
|
||||
"""
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):
|
||||
locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
locator = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
try:
|
||||
old_location, course, item, lms_link = _get_item_in_course(request, locator)
|
||||
except ItemNotFoundError:
|
||||
|
||||
@@ -60,12 +60,12 @@ __all__ = ['course_info_handler', 'course_handler', 'course_info_update_handler'
|
||||
'textbooks_list_handler', 'textbooks_detail_handler']
|
||||
|
||||
|
||||
def _get_locator_and_course(course_id, branch, version_guid, block_id, user, depth=0):
|
||||
def _get_locator_and_course(package_id, branch, version_guid, block_id, user, depth=0):
|
||||
"""
|
||||
Internal method used to calculate and return the locator and course module
|
||||
for the view functions in this file.
|
||||
"""
|
||||
locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block_id)
|
||||
locator = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block_id)
|
||||
if not has_access(user, locator):
|
||||
raise PermissionDenied()
|
||||
course_location = loc_mapper().translate_locator_to_location(locator)
|
||||
@@ -75,7 +75,7 @@ def _get_locator_and_course(course_id, branch, version_guid, block_id, user, dep
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@login_required
|
||||
def course_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def course_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for course specific requests.
|
||||
It provides the course tree with the necessary information for identifying and labeling the parts. The root
|
||||
@@ -93,7 +93,7 @@ def course_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
index entry.
|
||||
PUT
|
||||
json: update this course (index entry not xblock) such as repointing head, changing display name, org,
|
||||
course_id, prettyid. Return same json as above.
|
||||
package_id, prettyid. Return same json as above.
|
||||
DELETE
|
||||
json: delete this branch from this course (leaving off /branch/draft would imply delete the course)
|
||||
"""
|
||||
@@ -104,7 +104,7 @@ def course_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
return create_new_course(request)
|
||||
elif not has_access(
|
||||
request.user,
|
||||
BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
):
|
||||
raise PermissionDenied()
|
||||
elif request.method == 'PUT':
|
||||
@@ -114,10 +114,10 @@ def course_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
elif request.method == 'GET': # assume html
|
||||
if course_id is None:
|
||||
if package_id is None:
|
||||
return course_listing(request)
|
||||
else:
|
||||
return course_index(request, course_id, branch, version_guid, block)
|
||||
return course_index(request, package_id, branch, version_guid, block)
|
||||
else:
|
||||
return HttpResponseNotFound()
|
||||
|
||||
@@ -157,9 +157,7 @@ def course_listing(request):
|
||||
course.display_name,
|
||||
# note, couldn't get django reverse to work; so, wrote workaround
|
||||
course_loc.url_reverse('course/', ''),
|
||||
get_lms_link_for_item(
|
||||
course.location
|
||||
),
|
||||
get_lms_link_for_item(course.location),
|
||||
course.display_org_with_default,
|
||||
course.display_number_with_default,
|
||||
course.location.name
|
||||
@@ -175,14 +173,14 @@ def course_listing(request):
|
||||
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
def course_index(request, course_id, branch, version_guid, block):
|
||||
def course_index(request, package_id, branch, version_guid, block):
|
||||
"""
|
||||
Display an editable course overview.
|
||||
|
||||
org, course, name: Attributes of the Location for the item to edit
|
||||
"""
|
||||
locator, course = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user, depth=3
|
||||
package_id, branch, version_guid, block, request.user, depth=3
|
||||
)
|
||||
lms_link = get_lms_link_for_item(course.location)
|
||||
sections = course.get_children()
|
||||
@@ -315,13 +313,13 @@ def create_new_course(request):
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(["GET"])
|
||||
def course_info_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def course_info_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
GET
|
||||
html: return html for editing the course info handouts and updates.
|
||||
"""
|
||||
__, course_module = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user
|
||||
package_id, branch, version_guid, block, request.user
|
||||
)
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):
|
||||
handouts_old_location = course_module.location.replace(category='course_info', name='handouts')
|
||||
@@ -352,7 +350,7 @@ def course_info_handler(request, tag=None, course_id=None, branch=None, version_
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT", "DELETE"))
|
||||
@expect_json
|
||||
def course_info_update_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None,
|
||||
def course_info_update_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None,
|
||||
provided_id=None):
|
||||
"""
|
||||
restful CRUD operations on course_info updates.
|
||||
@@ -366,7 +364,7 @@ def course_info_update_handler(request, tag=None, course_id=None, branch=None, v
|
||||
"""
|
||||
if 'application/json' not in request.META.get('HTTP_ACCEPT', 'application/json'):
|
||||
return HttpResponseBadRequest("Only supports json requests")
|
||||
updates_locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
updates_locator = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
updates_location = loc_mapper().translate_locator_to_location(updates_locator)
|
||||
if provided_id == '':
|
||||
provided_id = None
|
||||
@@ -400,7 +398,7 @@ def course_info_update_handler(request, tag=None, course_id=None, branch=None, v
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "PUT", "POST"))
|
||||
@expect_json
|
||||
def settings_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def settings_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
Course settings for dates and about pages
|
||||
GET
|
||||
@@ -410,7 +408,7 @@ def settings_handler(request, tag=None, course_id=None, branch=None, version_gui
|
||||
json: update the Course and About xblocks through the CourseDetails model
|
||||
"""
|
||||
locator, course_module = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user
|
||||
package_id, branch, version_guid, block, request.user
|
||||
)
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
|
||||
upload_asset_url = locator.url_reverse('assets/')
|
||||
@@ -444,7 +442,7 @@ def settings_handler(request, tag=None, course_id=None, branch=None, version_gui
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT", "DELETE"))
|
||||
@expect_json
|
||||
def grading_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None, grader_index=None):
|
||||
def grading_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None, grader_index=None):
|
||||
"""
|
||||
Course Grading policy configuration
|
||||
GET
|
||||
@@ -456,7 +454,7 @@ def grading_handler(request, tag=None, course_id=None, branch=None, version_guid
|
||||
json w/ grader_index: create or update the specific grader (create if index out of range)
|
||||
"""
|
||||
locator, course_module = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user
|
||||
package_id, branch, version_guid, block, request.user
|
||||
)
|
||||
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
|
||||
@@ -550,7 +548,7 @@ def _config_course_advanced_components(request, course_module):
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT"))
|
||||
@expect_json
|
||||
def advanced_settings_handler(request, course_id=None, branch=None, version_guid=None, block=None, tag=None):
|
||||
def advanced_settings_handler(request, package_id=None, branch=None, version_guid=None, block=None, tag=None):
|
||||
"""
|
||||
Course settings configuration
|
||||
GET
|
||||
@@ -562,7 +560,7 @@ def advanced_settings_handler(request, course_id=None, branch=None, version_guid
|
||||
of keys whose values to unset: i.e., revert to default
|
||||
"""
|
||||
locator, course_module = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user
|
||||
package_id, branch, version_guid, block, request.user
|
||||
)
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
|
||||
|
||||
@@ -652,7 +650,7 @@ def assign_textbook_id(textbook, used_ids=()):
|
||||
@require_http_methods(("GET", "POST", "PUT"))
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
def textbooks_list_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def textbooks_list_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
A RESTful handler for textbook collections.
|
||||
|
||||
@@ -665,7 +663,7 @@ def textbooks_list_handler(request, tag=None, course_id=None, branch=None, versi
|
||||
json: overwrite all textbooks in the course with the given list
|
||||
"""
|
||||
locator, course = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user
|
||||
package_id, branch, version_guid, block, request.user
|
||||
)
|
||||
store = get_modulestore(course.location)
|
||||
|
||||
@@ -729,7 +727,7 @@ def textbooks_list_handler(request, tag=None, course_id=None, branch=None, versi
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT", "DELETE"))
|
||||
def textbooks_detail_handler(request, tid, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def textbooks_detail_handler(request, tid, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
JSON API endpoint for manipulating a textbook via its internal ID.
|
||||
Used by the Backbone application.
|
||||
@@ -742,7 +740,7 @@ def textbooks_detail_handler(request, tid, tag=None, course_id=None, branch=None
|
||||
json: remove textbook
|
||||
"""
|
||||
__, course = _get_locator_and_course(
|
||||
course_id, branch, version_guid, block, request.user
|
||||
package_id, branch, version_guid, block, request.user
|
||||
)
|
||||
store = get_modulestore(course.location)
|
||||
matching_id = [tb for tb in course.pdf_textbooks
|
||||
|
||||
@@ -50,7 +50,7 @@ CONTENT_RE = re.compile(r"(?P<start>\d{1,11})-(?P<stop>\d{1,11})/(?P<end>\d{1,11
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT"))
|
||||
def import_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def import_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for importing a course.
|
||||
|
||||
@@ -60,7 +60,7 @@ def import_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
POST or PUT
|
||||
json: import a course via the .tar.gz file specified in request.FILES
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, location):
|
||||
raise PermissionDenied()
|
||||
|
||||
@@ -148,7 +148,7 @@ def import_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
|
||||
# Use sessions to keep info about import progress
|
||||
session_status = request.session.setdefault("import_status", {})
|
||||
key = location.course_id + filename
|
||||
key = location.package_id + filename
|
||||
session_status[key] = 1
|
||||
request.session.modified = True
|
||||
|
||||
@@ -261,7 +261,7 @@ def import_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
@require_GET
|
||||
@ensure_csrf_cookie
|
||||
@login_required
|
||||
def import_status_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None, filename=None):
|
||||
def import_status_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None, filename=None):
|
||||
"""
|
||||
Returns an integer corresponding to the status of a file import. These are:
|
||||
|
||||
@@ -271,13 +271,13 @@ def import_status_handler(request, tag=None, course_id=None, branch=None, versio
|
||||
3 : Importing to mongo
|
||||
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, location):
|
||||
raise PermissionDenied()
|
||||
|
||||
try:
|
||||
session_status = request.session["import_status"]
|
||||
status = session_status[location.course_id + filename]
|
||||
status = session_status[location.package_id + filename]
|
||||
except KeyError:
|
||||
status = 0
|
||||
|
||||
@@ -287,7 +287,7 @@ def import_status_handler(request, tag=None, course_id=None, branch=None, versio
|
||||
@ensure_csrf_cookie
|
||||
@login_required
|
||||
@require_http_methods(("GET",))
|
||||
def export_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def export_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for exporting a course.
|
||||
|
||||
@@ -302,7 +302,7 @@ def export_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
If the tar.gz file has been requested but the export operation fails, an HTML page will be returned
|
||||
which describes the error.
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, location):
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ CREATE_IF_NOT_FOUND = ['course_info']
|
||||
@require_http_methods(("DELETE", "GET", "PUT", "POST"))
|
||||
@login_required
|
||||
@expect_json
|
||||
def xblock_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def xblock_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for xblock requests.
|
||||
|
||||
@@ -78,8 +78,8 @@ def xblock_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
:boilerplate: template name for populating fields, optional
|
||||
The locator (and old-style id) for the created xblock (minus children) is returned.
|
||||
"""
|
||||
if course_id is not None:
|
||||
locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if package_id is not None:
|
||||
locator = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, locator):
|
||||
raise PermissionDenied()
|
||||
old_location = loc_mapper().translate_locator_to_location(locator)
|
||||
@@ -117,7 +117,7 @@ def xblock_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
delete_all_versions = str_to_bool(request.REQUEST.get('all_versions', 'False'))
|
||||
|
||||
return _delete_item_at_location(old_location, delete_children, delete_all_versions)
|
||||
else: # Since we have a course_id, we are updating an existing xblock.
|
||||
else: # Since we have a package_id, we are updating an existing xblock.
|
||||
return _save_item(
|
||||
request,
|
||||
locator,
|
||||
@@ -133,7 +133,7 @@ def xblock_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
return _create_item(request)
|
||||
else:
|
||||
return HttpResponseBadRequest(
|
||||
"Only instance creation is supported without a course_id.",
|
||||
"Only instance creation is supported without a package_id.",
|
||||
content_type="text/plain"
|
||||
)
|
||||
|
||||
@@ -319,7 +319,7 @@ def _delete_item_at_location(item_location, delete_children=False, delete_all_ve
|
||||
# pylint: disable=W0613
|
||||
@login_required
|
||||
@require_http_methods(("GET", "DELETE"))
|
||||
def orphan_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def orphan_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
View for handling orphan related requests. GET gets all of the current orphans.
|
||||
DELETE removes all orphans (requires is_staff access)
|
||||
@@ -328,9 +328,9 @@ def orphan_handler(request, tag=None, course_id=None, branch=None, version_guid=
|
||||
from the root via children
|
||||
|
||||
:param request:
|
||||
:param course_id: Locator syntax course_id
|
||||
:param package_id: Locator syntax package_id
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
# DHM: when split becomes back-end, move or conditionalize this conversion
|
||||
old_location = loc_mapper().translate_locator_to_location(location)
|
||||
if request.method == 'GET':
|
||||
|
||||
@@ -48,7 +48,7 @@ def initialize_course_tabs(course):
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT"))
|
||||
def tabs_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
|
||||
def tabs_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
|
||||
"""
|
||||
The restful handler for static tabs.
|
||||
|
||||
@@ -62,7 +62,7 @@ def tabs_handler(request, tag=None, course_id=None, branch=None, version_guid=No
|
||||
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).
|
||||
"""
|
||||
locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
locator = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, locator):
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ def request_course_creator(request):
|
||||
@login_required
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "POST", "PUT", "DELETE"))
|
||||
def course_team_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None, email=None):
|
||||
def course_team_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None, email=None):
|
||||
"""
|
||||
The restful handler for course team users.
|
||||
|
||||
@@ -52,7 +52,7 @@ def course_team_handler(request, tag=None, course_id=None, branch=None, version_
|
||||
DELETE:
|
||||
json: remove a particular course team member from the course team (email is required).
|
||||
"""
|
||||
location = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
location = BlockUsageLocator(package_id=package_id, branch=branch, version_guid=version_guid, block_id=block)
|
||||
if not has_access(request.user, location):
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user