Exemple #1
0
    def get_contact_list(self, account, checked, page_num):
        '''
            Get contact list
        '''
        page_num = int(page_num)
        page_size = self.settings.get('page_size')
        contact_list = []

        # remove phone_2, phone_3 and contact_requests from query stuff and db.
        query = self.db.contacts.find(
            {
                'account':account,
                'checked':checked
            },
            {
                '_id':0,
                'phone_2':0,
                'phone_3':0,
                'contact_requests':0
            }
        )

        q = query

        q = q.sort([('_id', -1)]).skip(int(page_num) * page_size).limit(page_size)

        try:
            while (yield q.fetch_next):
                contact = contacts.Contact(q.next_object())
                contact_list.append(clean_structure(contact))
        except Exception, e:
            logging.exception(e)
            raise gen.Return(e)
Exemple #2
0
    def get_contact(self, account, contact_uuid):
        '''
            Get contact
        '''
        message = None
        logging.info('{0} get contact {1}'.format(account, contact_uuid))
        try:
            result = yield self.db.contacts.find_one(
                {
                    'account': account,
                    'uuid': contact_uuid
                },
                {
                    '_id': 0,
                    'phone_2': 0,
                    'phone_3': 0,
                    'contact_requests': 0
                }  # remove this stuff from db.
            )

            logging.info('{0} this is the result'.format(str(result)))
            if result:
                contact = contacts.Contact(result)
                contact.validate()
                message = clean_structure(contact)
        except Exception, e:
            logging.exception(e)
            raise e
Exemple #3
0
    def get_contact_list(self, account, checked, page_num):
        '''
            Get contact list
        '''
        page_num = int(page_num)
        page_size = self.settings.get('page_size')
        contact_list = []

        # remove phone_2, phone_3 and contact_requests from query stuff and db.
        query = self.db.contacts.find({
            'account': account,
            'checked': checked
        }, {
            '_id': 0,
            'phone_2': 0,
            'phone_3': 0,
            'contact_requests': 0
        })

        q = query

        q = q.sort([('_id', -1)
                    ]).skip(int(page_num) * page_size).limit(page_size)

        try:
            while (yield q.fetch_next):
                contact = contacts.Contact(q.next_object())
                contact_list.append(clean_structure(contact))
        except Exception, e:
            logging.exception(e)
            raise gen.Return(e)
Exemple #4
0
 def replace_contact(self, account, contact_uuid, struct):
     '''
         Replace contact
     '''
     try:
         contact = contacts.Contact(struct)
         contact.validate()
         contact = clean_structure(contact)
     except Exception, e:
         logging.error(e)
         raise e
Exemple #5
0
 def modify_contact(self, account, contact_uuid, struct):
     '''
         Modify contact
     '''
     try:
         contact = contacts.ModifyContact(struct)
         contact.validate()
         contact = clean_structure(contact)
     except Exception, e:
         logging.error(e)
         raise e
Exemple #6
0
 def replace_contact(self, account, contact_uuid, struct):
     '''
         Replace contact
     '''
     try:
         contact = contacts.Contact(struct)
         contact.validate()
         contact = clean_structure(contact)
     except Exception, e:
         logging.error(e)
         raise e
Exemple #7
0
 def modify_contact(self, account, contact_uuid, struct):
     '''
         Modify contact
     '''
     try:
         contact = contacts.ModifyContact(struct)
         contact.validate()
         contact = clean_structure(contact)
     except Exception, e:
         logging.error(e)
         raise e
Exemple #8
0
 def new_contact(self, struct):
     '''
         New contact
     '''
     # if check dir fail remove directory uuid
     if not struct.get('has_directory', False):
         struct.pop('directory_uuid', None)
         
     try:
         contact = contacts.Contact(struct)
         contact.validate()
         contact = clean_structure(contact)
     except Exception, e:
         logging.error(e)
         raise e
Exemple #9
0
    def new_contact(self, struct):
        '''
            New contact
        '''
        # if check dir fail remove directory uuid
        if not struct.get('has_directory', False):
            struct.pop('directory_uuid', None)

        try:
            contact = contacts.Contact(struct)
            contact.validate()
            contact = clean_structure(contact)
        except Exception, e:
            logging.error(e)
            raise e
Exemple #10
0
    def get_contact(self, account, contact_uuid):
        '''
            Get contact
        '''
        message = None
        logging.info('{0} get contact {1}'.format(account, contact_uuid))
        try:
            result = yield self.db.contacts.find_one(
                {'account':account,
                 'uuid': contact_uuid},
                {'_id':0, 'phone_2':0, 'phone_3':0, 'contact_requests':0} # remove this stuff from db.
            )

            logging.info('{0} this is the result'.format(str(result)))
            if result:
                contact = contacts.Contact(result)
                contact.validate()
                message = clean_structure(contact)
        except Exception, e:
            logging.exception(e)
            raise e