-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.py
35 lines (27 loc) · 997 Bytes
/
post.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
from google.appengine.ext import db
from user import User
# Post Model
class Post(db.Model):
"""
Holds info about who wrote this post and when.
"""
user_id = db.StringProperty(required=True)
subject = db.StringProperty(required=True)
content = db.TextProperty(required=True)
created = db.DateTimeProperty(auto_now_add=True)
last_modified = db.DateTimeProperty(auto_now=True)
class Like(db.Model):
user_id = db.StringProperty(required=True)
post_id = db.StringProperty(required=True)
def getUserName(self):
user = User.by_id(self.user_id)
return user.user_id
class Comment(db.Model):
user_id = db.StringProperty(required=True)
post_id = db.StringProperty(required=True)
comment = db.TextProperty(required=True)
created = db.DateTimeProperty(auto_now_add=True)
last_modified = db.DateTimeProperty(auto_now=True)
def getUserName(self):
user = User.by_id(self.user_id)
return user.user_id