Commit 97331d4c by Diana Huang

Fix merge conflict

parent cfb7f99c
......@@ -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
......
......@@ -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
......@@ -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.
......
......@@ -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))
......
......@@ -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
......
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