Merge branch 'feature_362-simple_comments'
authorJoar Wandborg <git@wandborg.com>
Wed, 29 Jun 2011 14:12:33 +0000 (16:12 +0200)
committerJoar Wandborg <git@wandborg.com>
Wed, 29 Jun 2011 14:12:33 +0000 (16:12 +0200)
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'])