コード例 #1
0
ファイル: contact.py プロジェクト: josepot/Caliopen
 def _create(self, contact_id, params, add_func, return_obj):
     """Create sub object from param using add_func."""
     contact = CoreContact.get(self.user, contact_id)
     created = getattr(contact, add_func)(params)
     log.debug('Created object {} for contact {}'.format(
         created.address_id, contact.contact_id))
     return return_obj.build(created).serialize()
コード例 #2
0
ファイル: user.py プロジェクト: CaliOpen/Caliopen
 def contact(self):
     """User is a contact."""
     if self.contact_id is None:
         return None
     try:
         return CoreContact.get(self, self.contact_id)
     except NotFound:
         log.warn("contact {} not found for user {}".
                  format(self.contact_id, self.user_id))
         return None
コード例 #3
0
ファイル: user.py プロジェクト: pascalduez/Caliopen
 def contact(self):
     """User is a contact."""
     if self.contact_id is None:
         return None
     try:
         return CoreContact.get(self, self.contact_id)
     except NotFound:
         log.warn("contact {} not found for user {}".format(
             self.contact_id, self.user_id))
         return None
コード例 #4
0
    def collection_get(self):
        filter_params = {'limit': self.get_limit(),
                         'offset': self.get_offset()}
        log.debug('Filter parameters {}'.format(filter_params))
        results = CoreContact._model_class.search(self.user, **filter_params)
        data = []
        for item in results:
            try:
                c = ReturnContact.build(
                    CoreContact.get(self.user, item.contact_id)). \
                    serialize()
                data.append(c)
            except Exception as exc:
                log.error("unable to serialize contact : {}".format(exc))

        return {'contacts': data, 'total': results.hits.total}
コード例 #5
0
ファイル: contact.py プロジェクト: CaliOpen/Caliopen
    def collection_get(self):
        filter_params = {'limit': self.get_limit(),
                         'offset': self.get_offset()}
        log.debug('Filter parameters {}'.format(filter_params))
        results = CoreContact._model_class.search(self.user, **filter_params)
        data = []
        for item in results:
            try:
                c = ReturnContact.build(
                    CoreContact.get(self.user, item.contact_id)). \
                    serialize()
                data.append(c)
            except Exception as exc:
                log.error("unable to serialize contact : {}".format(exc))

        return {'contacts': data, 'total': results.hits.total}
コード例 #6
0
ファイル: contact.py プロジェクト: josepot/Caliopen
 def __init__(self, request):
     self.request = request
     self.user = request.authenticated_userid
     contact_id = self.request.matchdict.get('contact_id')
     self.contact = CoreContact.get(self.user, contact_id)
コード例 #7
0
ファイル: contact.py プロジェクト: josepot/Caliopen
 def _delete(self, relation_id, delete_func):
     """Delete sub object relation_id using delete_fund."""
     contact_id = self.request.validated['contact_id']
     contact = CoreContact.get(self.user, contact_id)
     return getattr(contact, delete_func)(relation_id)