thinks work, they just don't display prettily, and it is hard to actually use the assets due to links

This commit is contained in:
Lyla Fischer
2012-10-05 09:43:16 -04:00
committed by Calen Pennington
parent 7791a7c4aa
commit f26a4af75c
4 changed files with 42 additions and 122 deletions

View File

@@ -618,7 +618,7 @@ def upload_asset(request, org, course, coursename):
if not has_access(request.user, location):
return HttpResponseForbidden()
# Does the course actually exist?!?
# Does the course actually exist?!? Get anything from it to prove its existance
try:
item = modulestore().get_item(location)
@@ -813,11 +813,22 @@ def asset_index(request, org, course, name):
'course' : course,
'coursename' : name
})
course_reference = StaticContent.compute_location(org, course, name)
assets = contentstore().get_all_content_for_course(course_reference)
asset_display = []
for asset in assets:
id = asset['_id']
display_info = {}
display_info['displayname'] = asset['displayname']
display_info['uploadDate'] = asset['uploadDate']
contentstore_reference = StaticContent.compute_location(id['course'], id['org'], id['name'])
display_info['url'] = StaticContent.get_url_path_from_location(contentstore_reference)
asset_display.append(display_info)
course = modulestore().get_item(location)
sections = course.get_children()
print assets[0]
return render_to_response('asset_index.html', {
'sections': sections,
'assets': asset_display,
'upload_asset_callback_url': upload_asset_callback_url
})

View File

@@ -23,20 +23,22 @@
</tr>
</thead>
<tbody>
% for asset in assets:
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/3185/screenshots/149571/picture_39.png"></div>
<div class="thumb"><img src="${asset['url']}"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-1.jpg</a>
<a href="${asset['url']}" class="filename">${asset['displayname']}</a>
</td>
<td class="date-col">
10/2/2012
${asset['uploadDate']}
</td>
<td class="embed-col">
<a href="#">copy</a>
<a href="${asset['url']}">copy</a>
</td>
</tr>
% endfor
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/4573/screenshots/157708/final.png"></div>
@@ -51,118 +53,6 @@
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/15101/screenshots/228625/star_wars_lightsbaer_2.jpg"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-2.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/3185/screenshots/149571/picture_39.png"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-1.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/4573/screenshots/157708/final.png"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-2.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/15101/screenshots/228625/star_wars_lightsbaer_2.jpg"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-2.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/3185/screenshots/149571/picture_39.png"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-1.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/4573/screenshots/157708/final.png"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-2.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/15101/screenshots/228625/star_wars_lightsbaer_2.jpg"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-2.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
<tr>
<td class="thumb-col">
<div class="thumb"><img src="http://dribbble.s3.amazonaws.com/users/3185/screenshots/149571/picture_39.png"></div>
</td>
<td class="name-col">
<a href="#" class="filename">raygun-1.jpg</a>
</td>
<td class="date-col">
10/2/2012
</td>
<td class="embed-col">
<a href="#">copy</a>
</td>
</tr>
</tbody>
</table>
<nav class="pagination">

View File

@@ -65,4 +65,23 @@ class ContentStore(object):
raise NotImplementedError
def get_all_content_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'},
....
]
'''
raise NotImplementedError

View File

@@ -42,7 +42,7 @@ class MongoContentStore(ContentStore):
except NoFile:
raise NotFoundError()
def get_all_content_info_for_course(self, location):
def get_all_content_for_course(self, location):
'''
Returns a list of all static assets for a course. The return format is a list of dictionary elements. Example: