Commit 97331d4c by Diana Huang

Fix merge conflict

parent cfb7f99c
...@@ -15,7 +15,6 @@ from xmodule.modulestore import ModuleStoreEnum ...@@ -15,7 +15,6 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from opaque_keys.edx.keys import UsageKey, CourseKey from opaque_keys.edx.keys import UsageKey, CourseKey
from xmodule.modulestore.store_utilities import delete_course
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
......
...@@ -532,15 +532,12 @@ def _get_item(request, data): ...@@ -532,15 +532,12 @@ def _get_item(request, data):
Returns the item. Returns the item.
""" """
usage_key = UsageKey.from_string(data.get('locator')) 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, # This is placed before has_course_access() to validate the location,
# because has_course_access() raises r if location is invalid. # because has_course_access() raises r if location is invalid.
item = modulestore().get_item(usage_key) 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() raise PermissionDenied()
return item return item
...@@ -849,11 +849,7 @@ class MongoModuleStore(ModuleStoreWriteBase): ...@@ -849,11 +849,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
modules = self._load_items(course_id, list(items)) modules = self._load_items(course_id, list(items))
return modules return modules
<<<<<<< HEAD def create_course(self, org, course, run, user_id, fields=None, **kwargs):
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
""" """
Creates and returns the course. Creates and returns the course.
......
...@@ -70,7 +70,7 @@ class TestPublish(SplitWMongoCourseBoostrapper): ...@@ -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 # 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 # 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): 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 # verify status
item = self.draft_mongo.get_item(vert_location, 0) item = self.draft_mongo.get_item(vert_location, 0)
...@@ -79,7 +79,7 @@ class TestPublish(SplitWMongoCourseBoostrapper): ...@@ -79,7 +79,7 @@ class TestPublish(SplitWMongoCourseBoostrapper):
# delete the draft version of the discussion # delete the draft version of the discussion
location = self.old_course_key.make_usage_key('discussion', block_id='Discussion1') 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) 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") self.assertTrue(getattr(draft_vert, 'is_draft', False), "Deletion didn't convert parent to draft")
...@@ -89,10 +89,10 @@ class TestPublish(SplitWMongoCourseBoostrapper): ...@@ -89,10 +89,10 @@ class TestPublish(SplitWMongoCourseBoostrapper):
draft_vert.children.remove(other_child_loc) 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 = self.draft_mongo.get_item(self.old_course_key.make_usage_key('vertical', block_id='Vert2'), 0)
other_vert.children.append(other_child_loc) other_vert.children.append(other_child_loc)
self.draft_mongo.update_item(draft_vert, self.userid) self.draft_mongo.update_item(draft_vert, self.user_id)
self.draft_mongo.update_item(other_vert, self.userid) self.draft_mongo.update_item(other_vert, self.user_id)
# publish # 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) item = self.old_mongo.get_item(vert_location, 0)
self.assertNotIn(location, item.children) self.assertNotIn(location, item.children)
self.assertIsNone(self.draft_mongo.get_parent_location(location)) self.assertIsNone(self.draft_mongo.get_parent_location(location))
......
...@@ -20,7 +20,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): ...@@ -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 This class ensures the db gets created, opened, and cleaned up in addition to creating the course
Defines the following attrs on self: 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 * split_mongo: a pointer to the split mongo instance
* old_mongo: a pointer to the old_mongo instance * old_mongo: a pointer to the old_mongo instance
* draft_mongo: a pointer to the old draft instance * draft_mongo: a pointer to the old draft instance
...@@ -45,7 +45,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): ...@@ -45,7 +45,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
def setUp(self): def setUp(self):
self.db_config['collection'] = 'modulestore{0}'.format(uuid.uuid4().hex[:5]) 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() super(SplitWMongoCourseBoostrapper, self).setUp()
self.split_mongo = SplitMongoModuleStore( self.split_mongo = SplitMongoModuleStore(
None, None,
...@@ -90,7 +90,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): ...@@ -90,7 +90,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
mongo = self.old_mongo mongo = self.old_mongo
else: else:
mongo = self.draft_mongo 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): if isinstance(data, basestring):
fields = {'data': data} fields = {'data': data}
else: else:
...@@ -105,7 +105,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): ...@@ -105,7 +105,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
mongo = self.draft_mongo mongo = self.draft_mongo
parent = mongo.get_item(parent_location) parent = mongo.get_item(parent_location)
parent.children.append(location) parent.children.append(location)
mongo.update_item(parent, self.userid) mongo.update_item(parent, self.user_id)
# create pointer for split # create pointer for split
course_or_parent_locator = BlockUsageLocator( course_or_parent_locator = BlockUsageLocator(
course_key=self.split_course_key, course_key=self.split_course_key,
...@@ -115,7 +115,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): ...@@ -115,7 +115,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
else: else:
course_or_parent_locator = self.split_course_key course_or_parent_locator = self.split_course_key
if split: 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): def _create_course(self, split=True):
""" """
...@@ -135,7 +135,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase): ...@@ -135,7 +135,7 @@ class SplitWMongoCourseBoostrapper(unittest.TestCase):
if split: if split:
# split requires the course to be created separately from creating items # split requires the course to be created separately from creating items
self.split_mongo.create_course( 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) 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 self.old_course_key = old_course.id
......
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