import datetime
import mongoengine as me


# Based on: https://flask-mongoengine.readthedocs.org/en/latest/

class Post(me.Document):
    title = me.StringField(max_length=120, required=True)
    created_at = me.DateTimeField(default=datetime.datetime.now, required=True)
    content = me.StringField(required=True)
    published = me.BooleanField(required=True)

    # TODO: make sure this is what we want. It's based on the MongoEngine docs.
    # Doesn't seem to work
    #@me.queryset_manager
    #def live_posts(doc_cls, queryset):
        #return queryset.filter(published=True)


@@ -355,16 +355,365 @@
 ed=True)
+%0A    slug = me.StringField(max_length=155, required=True)%0A    comments = me.ListField(me.EmbeddedDocumentField('Comment'))%0A%0A    def get_absolute_url(self):%0A        return url_for('post', kwargs=%7B'slug': self.slug%7D)%0A%0A    meta = %7B%0A        'allow_inheritance': True,%0A        'indexes': %5B'-created_at', 'slug'%5D,%0A        'ordering': %5B'-created_at'%5D%0A    %7D
 %0A%0A    # 
@@ -928,8 +928,189 @@
 =True)%0A%0A
+class Comment(me.EmbeddedDocument):%0A    created_at = me.DateTimeField(default=datetime.datetime.now, required=True)%0A    body = me.StringField(verbose_name=%22Comment%22, required=True)%0A

Add comment class to models