import datetime
from flask import url_for
from tumblelog import db


class Post(db.DynamicDocument):
    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
    slug = db.StringField(max_length=255, required=True)
    school = db.StringField(max_length=255)
    phone = db.StringField(max_length=255)

    def get_absolute_url(slug):
        return url_for('post', kwargs={"slug": 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']
    }

class BlogPost(Post):
    about_you = db.StringField()


# class Video(Post):
#     embed_code = db.StringField(required=True)


# class Image(Post):
#     image_url = db.StringField(required=True, max_length=255)


# class Quote(Post):
#     body = db.StringField(required=True)
#     author = db.StringField(verbose_name="Author Name", required=True, max_length=255)


# 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)
