From fb204084a2beb732fb8072b595933cd445296fc9 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 3 Oct 2012 09:24:48 -0400 Subject: [PATCH] for get_all_content_info_for_course(), return a list of the MongoDB query rather than a cursor object. Also add some documentation (in a comment) as to what a caller should expect --- cms/djangoapps/contentstore/views.py | 2 +- .../lib/xmodule/xmodule/contentstore/mongo.py | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 32c12ab4a9..6c90e55d1a 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -515,7 +515,7 @@ def upload_asset(request, org, course, coursename): except: # catch, log, and continue as thumbnails are not a hard requirement logging.error('Failed to generate thumbnail for {0}. Continuing...'.format(name)) - raise + return HttpResponse('Upload completed') diff --git a/common/lib/xmodule/xmodule/contentstore/mongo.py b/common/lib/xmodule/xmodule/contentstore/mongo.py index 56079aa964..4b620e5abe 100644 --- a/common/lib/xmodule/xmodule/contentstore/mongo.py +++ b/common/lib/xmodule/xmodule/contentstore/mongo.py @@ -42,10 +42,29 @@ class MongoContentStore(ContentStore): raise NotFoundError() def get_all_content_info_for_course(self, location): + ''' + Returns a list of all static assets for a course. The return format is a list of dictionary elements. Example: + + [ + + {u'displayname': u'profile.jpg', u'chunkSize': 262144, u'length': 85374, + u'uploadDate': datetime.datetime(2012, 10, 3, 5, 41, 54, 183000), u'contentType': u'image/jpeg', + u'_id': {u'category': u'asset', u'name': u'profile.jpg', u'course': u'6.002x', u'tag': u'c4x', + u'org': u'MITx', u'revision': None}, u'md5': u'36dc53519d4b735eb6beba51cd686a0e'}, + + {u'displayname': u'profile.thumbnail.jpg', u'chunkSize': 262144, u'length': 4073, + u'uploadDate': datetime.datetime(2012, 10, 3, 5, 41, 54, 196000), u'contentType': u'image/jpeg', + u'_id': {u'category': u'asset', u'name': u'profile.thumbnail.jpg', u'course': u'6.002x', u'tag': u'c4x', + u'org': u'MITx', u'revision': None}, u'md5': u'ff1532598830e3feac91c2449eaa60d6'}, + + .... + + ] + ''' course_filter = Location(XASSET_LOCATION_TAG, category="asset",course=location.course,org=location.org) # 'borrow' the function 'location_to_query' from the Mongo modulestore implementation items = self.fs_files.find(location_to_query(course_filter)) - return items + return list(items)