From 2ab2ed7760270e2398aaa038d2e5421c9a73fb8d Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 26 Jul 2017 14:45:45 -0400 Subject: [PATCH] Return no libraries if org not specified Due to a bug in org=None vs org='', all libraries were being returned from the "optimization" in #15292. This fix returns no libraries on the default '' value. --- cms/djangoapps/contentstore/views/course.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 87904bc8fc..413a6ba390 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -464,10 +464,16 @@ def _accessible_libraries_iter(user, org=None): """ List all libraries available to the logged in user by iterating through all libraries. - If 'org' is present, only libraries from that org will be returned. + org (string): if not None, this value will limit the libraries returned. An empty + string will result in no libraries, and otherwise only libraries with the + specified org will be returned. The default value is None. """ + if org is not None: + libraries = [] if org == '' else modulestore().get_libraries(org=org) + else: + libraries = modulestore().get_libraries() # No need to worry about ErrorDescriptors - split's get_libraries() never returns them. - return (lib for lib in modulestore().get_libraries(org=org) if has_studio_read_access(user, lib.location.library_key)) + return (lib for lib in libraries if has_studio_read_access(user, lib.location.library_key)) @login_required