-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
81 lines (67 loc) · 2.51 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
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
78
79
80
import utils
import config
db = config.MAIN_DB
log = config.LOGGER
class Organization(db.Model):
__tablename__ = 'organizations'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String())
contact_email = db.Column(db.String())
description = db.Column(db.String())
zip_code = db.Column(db.String())
image_url = db.Column(db.String())
latitude = db.Column(db.String())
longitude = db.Column(db.String())
instructions = db.Column(db.String())
address = db.Column(db.String())
accepts_opened = db.Column(db.String())
city = db.Column(db.String())
state = db.Column(db.String())
def __init__(self, name, contact_email, description, image_url, zip_code,
latitude, longitude, instructions, address, accepts_opened,
city, state):
self.id = utils.get_next_id()
self.name = name
self.contact_email = contact_email
self.description = description
self.image_url = image_url
self.zip_code = zip_code
self.latitude = latitude
self.longitude = longitude
self.instructions = instructions
self.address = address
self.accepts_opened = accepts_opened
self.city = city
self.state = state
def __repr__(self):
return '<id {}>'.format(self.id)
def serialize(self):
return {
'id': self.id,
'name': self.name,
'contact_email': self.contact_email if not None else '',
'description': self.description if not None else '',
'image_url': self.image_url if not None else '',
'zip_code': self.zip_code if not None else '',
'longitude': self.longitude if not None else '',
'latitude': self.latitude if not None else '',
'instructions': self.instructions if not None else '',
'address': self.address if not None else '',
'accepts_opened': self.accepts_opened if not None else '',
'city': self.city if not None else '',
'state': self.state if not None else '',
}
class Need(db.Model):
__tablename__ = 'organization_needs'
org_id = db.Column(db.Integer, primary_key=True)
need = db.Column(db.String())
def __init__(self, org_id, need):
self.org_id = org_id
self.need = need
def __repr__(self):
return '<need {}>'.format(self.need)
def serialize(self):
return {
'org_id' : self.org_id,
'need': self.need
}