diff --git a/quokka/core/models.py b/quokka/core/models.py index 48c10f519..6ad470edb 100644 --- a/quokka/core/models.py +++ b/quokka/core/models.py @@ -17,9 +17,17 @@ class Publishable(object): class Slugged(object): slug = db.StringField(max_length=255, required=True) - + +class Comment(db.EmbeddedDocument, Publishable): + body = db.StringField(verbose_name="Comment", required=True) + author = db.StringField(verbose_name="Name", max_length=255, required=True) + published = db.BooleanField(default=True) + + def __unicode__(self): + return "{}-{}...".format(self.author, self.body[:10]) + class Commentable(object): - comments = db.ListField(db.ReferenceField('Comment')) + comments = db.ListField(db.EmbeddedDocumentField(Comment)) class Imaged(object): """TODO: IMplement ImageField""" @@ -75,15 +83,4 @@ def post_type(self): 'ordering': ['-created_at'] } - -class Comment(db.Document, Publishable): - body = db.StringField(verbose_name="Comment", required=True) - author = db.StringField(verbose_name="Name", max_length=255, required=True) - published = db.BooleanField(default=True) - - def __unicode__(self): - return "{}-{}...".format(self.author, self.body[:10]) - - -admin.register(Comment, category="content") admin.register(Channel) diff --git a/quokka/modules/posts/views.py b/quokka/modules/posts/views.py index 09f773288..fe7f8358e 100644 --- a/quokka/modules/posts/views.py +++ b/quokka/modules/posts/views.py @@ -44,7 +44,6 @@ def post(self, slug): if form.validate(): comment = Comment() form.populate_obj(comment) - comment.save(validate=False) post = context.get('post') post.comments.append(comment)