Exemplo n.º 1
0
 def get(self):
     contact_id = self.request.matchdict.get('contact_id')
     try:
         contact = CoreContact.get(self.user, contact_id)
     except NotFound:
         raise ResourceNotFound('No such contact')
     return {'contacts': ReturnContact.build(contact).serialize()}
Exemplo n.º 2
0
 def get(self):
     contact_id = self.request.matchdict.get('contact_id')
     try:
         contact = CoreContact.get(self.user, contact_id)
     except NotFound:
         raise ResourceNotFound('No such contact')
     return {'contacts': ReturnContact.build(contact).serialize()}
Exemplo n.º 3
0
 def collection_post(self):
     """Create a new contact from json post data structure."""
     data = self.request.json
     contact_param = NewContact(data)
     try:
         contact_param.validate()
     except Exception as exc:
         raise ValidationError(exc)
     contact = CoreContact.create(self.user, contact_param)
     out_contact = ReturnContact.build(contact).serialize()
     return Response(status=201, body={'contacts': out_contact})
Exemplo n.º 4
0
 def collection_post(self):
     """Create a new contact from json post data structure."""
     data = self.request.json
     contact_param = NewContact(data)
     try:
         contact_param.validate()
     except Exception as exc:
         raise ValidationError(exc)
     contact = CoreContact.create(self.user, contact_param)
     out_contact = ReturnContact.build(contact).serialize()
     return Response(status=201, body={'contacts': out_contact})