From: Joar Wandborg Date: Wed, 29 Jun 2011 14:12:33 +0000 (+0200) Subject: Merge branch 'feature_362-simple_comments' X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=47f524f67d90245521cb6214e269e89f06daeaf2;p=mediagoblin.git Merge branch 'feature_362-simple_comments' --- 47f524f67d90245521cb6214e269e89f06daeaf2 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'])