From: Christopher Allan Webber Date: Thu, 30 Jun 2011 01:27:48 +0000 (-0500) Subject: Merge remote branch 'remotes/jwandborg/feature_362-simple_comments' X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=216cd9c85c81f3dacb5211aa3beefae344fce487;p=mediagoblin.git Merge remote branch 'remotes/jwandborg/feature_362-simple_comments' --- 216cd9c85c81f3dacb5211aa3beefae344fce487 diff --cc mediagoblin/db/models.py index 8d06ae49,5196dede..bf825a23 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@@ -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'])