Added parameter ascending to MediaEntry::get_comments, if true, comments
authorPablo J. Urbano Santos <flamma@member.fsf.org>
Sat, 19 Nov 2011 18:11:42 +0000 (19:11 +0100)
committerPablo J. Urbano Santos <flamma@member.fsf.org>
Sat, 19 Nov 2011 18:11:42 +0000 (19:11 +0100)
will be ordered ascending, otherwise descending

mediagoblin/db/models.py

index 1c1bc2fd9ab47aef1ced53fb44ad9fc8bdde77e3..f13a4457677d22a33b33efe3cabd85819e335980 100644 (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):