-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
79 lines (64 loc) · 2.4 KB
/
Copy pathmodels.py
File metadata and controls
79 lines (64 loc) · 2.4 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from google.appengine.ext import ndb
class Person(ndb.Model):
user_id = ndb.StringProperty()
first_name = ndb.StringProperty()
last_name = ndb.StringProperty()
email = ndb.StringProperty()
active = ndb.BooleanProperty(default=False)
class Teacher(Person):
phone_number = ndb.StringProperty()
role_number = ndb.StringProperty()
subjects = ndb.StringProperty(repeated=True)
class Student(Person):
teacher = ndb.KeyProperty(kind=Teacher)
subject = ndb.StringProperty()
school_cycle = ndb.StringProperty()
parental_consent_received = ndb.BooleanProperty(default=False)
parental_consent_confirmed = ndb.BooleanProperty(default=False)
invitation_email_sent = ndb.BooleanProperty(default=False)
invitation_email_sent_date = ndb.DateTimeProperty(default=None)
competition_email_sent = ndb.BooleanProperty(default=False)
competition_email_sent_date = ndb.DateTimeProperty(default=None)
@classmethod
def get_by_email(cls, email):
"""Returns a student object based on an email.
:param email:
String representing the student email. Examples:
:returns:
A student object.
"""
return cls.query(cls.email == email).get()
@classmethod
def get_all(cls):
""" get all students """
return cls.query()
@classmethod
def get_consent_pending(cls):
""" get students who havent returned parental consent """
return cls.query(cls.parental_consent_received == False)
@classmethod
def get_consent_received(cls):
""" get students who have return parental consent
but havent been confirmed """
return cls.query(
ndb.AND(
cls.parental_consent_received == True,
cls.parental_consent_confirmed == False
)
)
@classmethod
def get_consent_confirmed(cls):
""" get students with confirmed parental consent """
return cls.query(
ndb.AND(
cls.parental_consent_received == True,
cls.parental_consent_confirmed == True
)
)
@classmethod
def get_invite_email_pending(cls):
""" get students with confirmed parental consent
who havent received their invite email """
students = cls.get_consent_confirmed().filter(
cls.invitation_email_sent == False)
return students