PLAT-1885 Stop using deprecated BlockUsageLocator properties

This commit is contained in:
Jeremy Bowman
2018-01-12 14:04:13 -05:00
parent c3abe79b09
commit 113e8dde61
51 changed files with 185 additions and 176 deletions

View File

@@ -135,7 +135,7 @@ class GroupConfiguration(object):
unit_url = reverse_usage_url(
'container_handler',
course.location.course_key.make_usage_key(unit_for_url.location.block_type, unit_for_url.location.name)
course.location.course_key.make_usage_key(unit_for_url.location.block_type, unit_for_url.location.block_id)
)
usage_dict = {'label': u"{} / {}".format(unit.display_name, item.display_name), 'url': unit_url}

View File

@@ -597,7 +597,7 @@ class CourseAboutSearchIndexer(object):
# load data for all of the 'about' modules for this course into a dictionary
about_dictionary = {
item.location.name: item.data
item.location.block_id: item.data
for item in modulestore.get_items(course.id, qualifiers={"category": "about"})
}

View File

@@ -299,7 +299,7 @@ class ImportRequiredTestCases(ContentStoreTestCase):
for item in items:
filesystem = OSFS(root_dir / ('test_export/' + dirname))
self.assertTrue(filesystem.exists(item.location.name + filename_suffix))
self.assertTrue(filesystem.exists(item.location.block_id + filename_suffix))
@mock.patch('xmodule.course_module.requests.get')
def test_export_course_roundtrip(self, mock_get):

View File

@@ -137,7 +137,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
vertical.location = vertical.location.replace(name='no_references')
self.store.update_item(vertical, self.user.id, allow_not_found=True)
orphan_vertical = self.store.get_item(vertical.location)
self.assertEqual(orphan_vertical.location.name, 'no_references')
self.assertEqual(orphan_vertical.location.block_id, 'no_references')
self.assertEqual(len(orphan_vertical.children), len(vertical.children))
# create an orphan vertical and html; we already don't try to import

View File

@@ -541,7 +541,7 @@ def _delete_thumbnail(thumbnail_location, course_key, asset_key):
# We are ignoring the value of the thumbnail_location-- we only care whether
# or not a thumbnail has been stored, and we can now easily create the correct path.
thumbnail_location = course_key.make_asset_key('thumbnail', asset_key.name)
thumbnail_location = course_key.make_asset_key('thumbnail', asset_key.block_id)
try:
thumbnail_content = contentstore().find(thumbnail_location)

View File

@@ -282,7 +282,7 @@ def create_xblock(parent_locator, user, category, display_name, boilerplate=None
course.tabs.append(
StaticTab(
name=display_name,
url_slug=dest_usage_key.name,
url_slug=dest_usage_key.block_id,
)
)
store.update_item(course, user.id)
@@ -298,7 +298,7 @@ def is_item_in_course_tree(item):
if its parent has been deleted and is now an orphan.
"""
ancestor = item.get_parent()
while ancestor is not None and ancestor.location.category != "course":
while ancestor is not None and ancestor.location.block_type != "course":
ancestor = ancestor.get_parent()
return ancestor is not None

View File

@@ -585,7 +585,7 @@ def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None,
# for static tabs, their containing course also records their display name
course = store.get_course(xblock.location.course_key)
if xblock.location.category == 'static_tab':
if xblock.location.block_type == 'static_tab':
# find the course's reference to this tab and update the name.
static_tab = CourseTabList.get_tab_by_slug(course.tabs, xblock.location.name)
# only update if changed
@@ -916,7 +916,7 @@ def _delete_item(usage_key, user):
# VS[compat] cdodge: This is a hack because static_tabs also have references from the course module, so
# if we add one then we need to also add it to the policy information (i.e. metadata)
# we should remove this once we can break this reference from the course to static tabs
if usage_key.category == 'static_tab':
if usage_key.block_type == 'static_tab':
dog_stats_api.increment(
DEPRECATION_VSCOMPAT_EVENT,
@@ -928,7 +928,7 @@ def _delete_item(usage_key, user):
course = store.get_course(usage_key.course_key)
existing_tabs = course.tabs or []
course.tabs = [tab for tab in existing_tabs if tab.get('url_slug') != usage_key.name]
course.tabs = [tab for tab in existing_tabs if tab.get('url_slug') != usage_key.block_id]
store.update_item(course, user.id)
store.delete_item(usage_key, user.id)
@@ -988,7 +988,7 @@ def _get_xblock(usage_key, user):
try:
return store.get_item(usage_key, depth=None)
except ItemNotFoundError:
if usage_key.category in CREATE_IF_NOT_FOUND:
if usage_key.block_type in CREATE_IF_NOT_FOUND:
# Create a new one for certain categories only. Used for course info handouts.
return store.create_item(user.id, usage_key.course_key, usage_key.block_type, block_id=usage_key.block_id)
else:

View File

@@ -208,7 +208,7 @@ def library_blocks_view(library, user, response_format):
return JsonResponse({
"display_name": library.display_name,
"library_id": unicode(library.location.library_key),
"version": unicode(library.runtime.course_entry.course_key.version),
"version": unicode(library.runtime.course_entry.course_key.version_guid),
"previous_version": unicode(prev_version) if prev_version else None,
"blocks": [unicode(x) for x in children],
})

View File

@@ -270,7 +270,7 @@ class CourseUpdateTest(CourseTestCase):
updates_location = self.course.id.make_usage_key('course_info', 'updates')
self.assertTrue(isinstance(updates_location, UsageKey))
self.assertEqual(updates_location.name, u'updates')
self.assertEqual(updates_location.block_id, u'updates')
# check posting on handouts
handouts_location = self.course.id.make_usage_key('course_info', 'handouts')