From e62fc61194508ed5233cdc78e90747450343616f Mon Sep 17 00:00:00 2001 From: "Pablo J. Urbano Santos" Date: Sat, 19 Nov 2011 19:11:42 +0100 Subject: [PATCH 1/2] Added parameter ascending to MediaEntry::get_comments, if true, comments will be ordered ascending, otherwise descending --- mediagoblin/db/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 1c1bc2fd..f13a4457 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -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): From 1a3138addd43d410b03cdd1816e0a62bd217de30 Mon Sep 17 00:00:00 2001 From: "Pablo J. Urbano Santos" Date: Sat, 19 Nov 2011 19:15:41 +0100 Subject: [PATCH 2/2] media_home: order comments by ascending date. --- mediagoblin/user_pages/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 82865bb4..98a21bb4 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -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()