Merge remote branch 'remotes/jwandborg/feature_362-simple_comments'
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 30 Jun 2011 01:27:48 +0000 (20:27 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 30 Jun 2011 01:27:48 +0000 (20:27 -0500)
1  2 
mediagoblin/db/models.py

index 8d06ae49505937751e2cf8b2c59a9a4864a15c9c,5196dedea260952c793dcb1e5e09aeda1aa11535..bf825a2391bc82b20b7bb4989b92d76c325b6e66
@@@ -108,9 -109,29 +109,24 @@@ class MediaEntry(Document)
  
      migration_handler = migrations.MediaEntryMigration
  
 -    indexes = [
 -        # Referene uniqueness of slugs by uploader
 -        {'fields': ['uploader', 'slug'],
 -         'unique': True}]
 -
      def main_mediafile(self):
          pass
+     
+     def get_comments(self, page):
+         cursor = self.db.MediaComment.find({
+                 'media_entry': self['_id']}).sort('created', DESCENDING)
+         
+         pagination = Pagination(page, cursor)
+         comments = pagination()
+         
+         data = list()
+         for comment in comments:
+             comment['author'] = self.db.User.find_one({
+                     '_id': comment['author']})
+             data.append(comment)
+             
+         return (data, pagination)
+         
      def generate_slug(self):
          self['slug'] = util.slugify(self['title'])