diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 49c210caaa..399aaa7f5c 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -15,7 +15,6 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError from opaque_keys.edx.keys import UsageKey, CourseKey -from xmodule.modulestore.store_utilities import delete_course from student.roles import CourseInstructorRole, CourseStaffRole diff --git a/cms/djangoapps/contentstore/views/transcripts_ajax.py b/cms/djangoapps/contentstore/views/transcripts_ajax.py index 623bfd83fa..57e8e2614e 100644 --- a/cms/djangoapps/contentstore/views/transcripts_ajax.py +++ b/cms/djangoapps/contentstore/views/transcripts_ajax.py @@ -532,15 +532,12 @@ def _get_item(request, data): Returns the item. """ usage_key = UsageKey.from_string(data.get('locator')) - - # usage_key's course_key may have an empty run property - usage_key = usage_key.replace(course_key=modulestore().fill_in_run(usage_key.course_key)) - # This is placed before has_course_access() to validate the location, # because has_course_access() raises r if location is invalid. item = modulestore().get_item(usage_key) - if not has_course_access(request.user, usage_key.course_key): + # use the item's course_key, because the usage_key might not have the run + if not has_course_access(request.user, item.location.course_key): raise PermissionDenied() return item diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index 6b35628d1f..d3043f2d77 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -849,11 +849,7 @@ class MongoModuleStore(ModuleStoreWriteBase): modules = self._load_items(course_id, list(items)) return modules -<<<<<<< HEAD - def create_course(self, org, offering, user_id, fields=None, **kwargs): -======= - def create_course(self, org, course, run, user_id=None, fields=None, **kwargs): ->>>>>>> Fix up the signature to use course and run instead of just offering + def create_course(self, org, course, run, user_id, fields=None, **kwargs): """ Creates and returns the course. diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py b/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py index b6f0171b23..f0226e5f7c 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py @@ -70,7 +70,7 @@ class TestPublish(SplitWMongoCourseBoostrapper): # 02-July-2014 send calls are 7. 5 from above, plus 2 for updating subtree edit info for Chapter1 and course # find calls are 22. 19 from above, plus 3 for finding the parent of Vert1, Chapter1, and course with check_mongo_calls(self.draft_mongo, 22, 7): - self.draft_mongo.publish(item.location, self.userid) + self.draft_mongo.publish(item.location, self.user_id) # verify status item = self.draft_mongo.get_item(vert_location, 0) @@ -79,7 +79,7 @@ class TestPublish(SplitWMongoCourseBoostrapper): # delete the draft version of the discussion location = self.old_course_key.make_usage_key('discussion', block_id='Discussion1') - self.draft_mongo.delete_item(location, self.userid) + self.draft_mongo.delete_item(location, self.user_id) draft_vert = self.draft_mongo.get_item(vert_location, 0) self.assertTrue(getattr(draft_vert, 'is_draft', False), "Deletion didn't convert parent to draft") @@ -89,10 +89,10 @@ class TestPublish(SplitWMongoCourseBoostrapper): draft_vert.children.remove(other_child_loc) other_vert = self.draft_mongo.get_item(self.old_course_key.make_usage_key('vertical', block_id='Vert2'), 0) other_vert.children.append(other_child_loc) - self.draft_mongo.update_item(draft_vert, self.userid) - self.draft_mongo.update_item(other_vert, self.userid) + self.draft_mongo.update_item(draft_vert, self.user_id) + self.draft_mongo.update_item(other_vert, self.user_id) # publish - self.draft_mongo.publish(vert_location, self.userid) + self.draft_mongo.publish(vert_location, self.user_id) item = self.old_mongo.get_item(vert_location, 0) self.assertNotIn(location, item.children) self.assertIsNone(self.draft_mongo.get_parent_location(location)) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py index aab59d0463..82d5c0d72e 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py @@ -20,7 +20,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): This class ensures the db gets created, opened, and cleaned up in addition to creating the course Defines the following attrs on self: - * userid: a random non-registered mock user id + * user_id: a random non-registered mock user id * split_mongo: a pointer to the split mongo instance * old_mongo: a pointer to the old_mongo instance * draft_mongo: a pointer to the old draft instance @@ -45,7 +45,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): def setUp(self): self.db_config['collection'] = 'modulestore{0}'.format(uuid.uuid4().hex[:5]) - self.userid = random.getrandbits(32) + self.user_id = random.getrandbits(32) super(SplitWMongoCourseBoostrapper, self).setUp() self.split_mongo = SplitMongoModuleStore( None, @@ -90,7 +90,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): mongo = self.old_mongo else: mongo = self.draft_mongo - mongo.create_and_save_xmodule(location, self.userid, definition_data=data, metadata=metadata, runtime=self.runtime) + mongo.create_and_save_xmodule(location, self.user_id, definition_data=data, metadata=metadata, runtime=self.runtime) if isinstance(data, basestring): fields = {'data': data} else: @@ -105,7 +105,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): mongo = self.draft_mongo parent = mongo.get_item(parent_location) parent.children.append(location) - mongo.update_item(parent, self.userid) + mongo.update_item(parent, self.user_id) # create pointer for split course_or_parent_locator = BlockUsageLocator( course_key=self.split_course_key, @@ -115,7 +115,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): else: course_or_parent_locator = self.split_course_key if split: - self.split_mongo.create_item(course_or_parent_locator, category, self.userid, block_id=name, fields=fields) + self.split_mongo.create_item(course_or_parent_locator, category, self.user_id, block_id=name, fields=fields) def _create_course(self, split=True): """ @@ -135,7 +135,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): if split: # split requires the course to be created separately from creating items self.split_mongo.create_course( - self.split_course_key.org, self.split_course_key.course, self.split_course_key.run, self.userid, fields=fields, root_block_id='runid' + self.split_course_key.org, self.split_course_key.course, self.split_course_key.run, self.user_id, fields=fields, root_block_id='runid' ) old_course = self.old_mongo.create_course(self.split_course_key.org, 'test_course', 'runid', self.user_id, fields=fields) self.old_course_key = old_course.id