-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathHelpRequest.py
More file actions
26 lines (20 loc) · 906 Bytes
/
HelpRequest.py
File metadata and controls
26 lines (20 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from google.appengine.ext import ndb
HELP_QUEUE_NAME = 'default_queue'
def help_queue_key(help__queue_name=HELP_QUEUE_NAME):
return ndb.Key('HelpQueue', help__queue_name)
class HelpRequest(ndb.Model):
name = ndb.StringProperty()
netid = ndb.StringProperty()
help_msg = ndb.TextProperty()
been_helped = ndb.BooleanProperty(default=False)
canceled = ndb.BooleanProperty(default=False)
in_queue = ndb.ComputedProperty(lambda self:
(not self.been_helped and
not self.canceled))
request_datetime = ndb.DateTimeProperty(auto_now_add=True)
attending_ta = ndb.StringProperty()
helped_datetime = ndb.DateTimeProperty()
course = ndb.StringProperty()
@property
def wait_time(self):
return None if self.helped_datetime is None else (self.helped_datetime - self.request_datetime)