Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Comments are Embedded again, found the problem syrusakbary/Flask-Supe…
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Jul 14, 2013
1 parent 297ae79 commit 1ab5757
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
23 changes: 10 additions & 13 deletions quokka/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion quokka/modules/posts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ab5757

Please sign in to comment.