-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.py
43 lines (35 loc) · 1.21 KB
/
model.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
from google.appengine.ext import db
from datetime import datetime,timedelta
class LastSearch(db.Model):
id = db.IntegerProperty()
date = db.DateTimeProperty(auto_now_add=True)
def __repr__(self):
return "<lastsearch id='%s' date='%s' />" % (self.id, self.date)
class EpicTweet(db.Model):
tweet_id = db.IntegerProperty()
sender = db.StringProperty()
sender_id = db.IntegerProperty()
date = db.DateTimeProperty(auto_now_add=True)
original_text = db.StringProperty(multiline=True)
accepted = db.BooleanProperty()
replied = db.BooleanProperty()
reject_reason = db.StringProperty(multiline=True)
def toHtml(self):
return """
<li>
On %s %s said: <br/>
<pre>%s</pre>
</li>""" % (self.date-timedelta(hours=6), self.sender,
self.original_text)
def __repr__(self):
return """
<EpicTweet id='%d' accepted='%s' replied='%s'>
<date>%s</date>
<age>%s</age>
<sender name='%s' id='%d'/>
<text>%s</text>
</EpicTweet>""" % (self.tweet_id, self.accepted, self.replied,
self.date, self.age(), self.sender, self.sender_id,
self.original_text)
def age(self):
return datetime.utcnow() - self.date