From: Pablo J. Urbano Santos Date: Sat, 19 Nov 2011 18:11:42 +0000 (+0100) Subject: Added parameter ascending to MediaEntry::get_comments, if true, comments X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e62fc61194508ed5233cdc78e90747450343616f;p=mediagoblin.git Added parameter ascending to MediaEntry::get_comments, if true, comments will be ordered ascending, otherwise descending --- 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):