Merge remote branch 'remotes/inconexo/441_comment_order'

This commit is contained in:
Christopher Allan Webber 2011-11-19 13:54:49 -06:00
commit 5db324f7c6
2 changed files with 9 additions and 4 deletions

View File

@ -217,9 +217,14 @@ class MediaEntry(Document):
'created': datetime.datetime.utcnow,
'state': u'unprocessed'}
def get_comments(self):
def get_comments(self, ascending=False):
if ascending:
order = ASCENDING
else:
order = DESCENDING
return self.db.MediaComment.find({
'media_entry': self._id}).sort('created', DESCENDING)
'media_entry': self._id}).sort('created', order)
def get_display_media(self, media_map,
fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):

View File

@ -106,11 +106,11 @@ def media_home(request, media, page, **kwargs):
"""
if ObjectId(request.matchdict.get('comment')):
pagination = Pagination(
page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE,
page, media.get_comments(True), MEDIA_COMMENTS_PER_PAGE,
ObjectId(request.matchdict.get('comment')))
else:
pagination = Pagination(
page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE)
page, media.get_comments(True), MEDIA_COMMENTS_PER_PAGE)
comments = pagination()