2012-05-18 15:18:41 +00:00
|
|
|
|
from server.families import Families
|
2012-05-29 20:41:47 +00:00
|
|
|
|
from server.helpers import json_loads_from_request
|
2012-05-18 15:18:41 +00:00
|
|
|
|
|
|
|
|
|
__families__ = Families()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if GET:
|
|
|
|
|
response.body = __families__.getall()
|
|
|
|
|
elif POST:
|
2012-05-29 20:41:47 +00:00
|
|
|
|
family = json_loads_from_request(request)['family']
|
2012-05-18 15:18:41 +00:00
|
|
|
|
family_id = __families__.add(family)
|
|
|
|
|
response.headers['Location'] = '/families/{}.json'.format(family_id)
|
|
|
|
|
family['id'] = family_id
|
|
|
|
|
response.body = family
|
|
|
|
|
response.code = 201
|
|
|
|
|
|
|
|
|
|
# vim:filetype=python
|