Commit 13ff4614 by Chris Dodge

add a filter to get_courses to not surface any courses that haven't been mapped,…

add a filter to get_courses to not surface any courses that haven't been mapped, unless the store provider has been labeled as 'default'
parent ae6f97a3
......@@ -103,7 +103,20 @@ class MixedModuleStore(ModuleStoreBase):
'''
courses = []
for key in self.modulestores:
courses = courses + (self.modulestores[key].get_courses())
store_courses = self.modulestores[key].get_courses()
# If the store has not been labeled as 'default' then we should
# only surface courses that have a mapping entry, for example the XMLModuleStore will
# slurp up anything that is on disk, however, we don't want to surface those to
# consumers *unless* there is an explicit mapping in the configuration
if key != 'default':
for course in store_courses:
# make sure that the courseId is mapped to the store in question
if key == self.mappings.get(course.location.course_id, 'default'):
courses = courses + ([course])
else:
# if we're the 'default' store provider, then we surface all courses hosted in
# that store provider
courses = courses + (store_courses)
return courses
......
......@@ -187,6 +187,7 @@ class TestMixedModuleStore(object):
def test_get_courses(self):
# we should have 3 total courses aggregated
courses = self.store.get_courses()
assert_equals(len(courses), 3)
course_ids = []
for course in courses:
course_ids.append(course.location.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