Esempio n. 1
0
class Post(db.DynamicDocument):
    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
    title = db.StringField(max_length=255, required=True)
    slug = db.StringField(max_length=255, required=True)
    category = db.StringField(max_length=255, required=True)
    tags = db.StringField(required=False)
    comments = db.ListField(db.EmbeddedDocumentField('Comment'))

    def get_absolute_url(self):
        return url_for('post', kwargs={"slug": self.slug})

    def __unicode__(self):
        return self.title

    @property
    def post_type(self):
        return self.__class__.__name__

    meta = {
        'allow_inheritance': True,
        'indexes': ['-created_at', 'slug'],
        'ordering': ['-created_at']
    }
Esempio n. 2
0
class Comment(db.EmbeddedDocument):
    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
    body = db.StringField(verbose_name="Comment", required=True)
    author = db.StringField(verbose_name="Name", max_length=255, required=True)
Esempio n. 3
0
class Quote(Post):
    body = db.StringField(required=True)
    author = db.StringField(verbose_name="Author Name",
                            required=True,
                            max_length=255)
Esempio n. 4
0
class Image(Post):
    image_url = db.StringField(required=True, max_length=255)
Esempio n. 5
0
class Video(Post):
    embed_code = db.StringField(required=True)
Esempio n. 6
0
class BlogPost(Post):
    body = db.StringField(required=True)