-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
48 lines (33 loc) · 1.29 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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)