示例#1
0
def contacts():
	if request.method == 'GET':
		results = Contact.all()

	json_results = []
	for result in results:
		d = {'id': result.key().id(),
			 'firstName': result.firstName,
			 'lastName': result.lastName,
			 'bday': result.bday,
			 'zodiac': result.zodiac}
		json_results.append(d)

	return jsonify(contacts=json_results)
示例#2
0
    def get(self):
        answer = []

        # Always put the default sender at the top.
        defaultSender = Contact.getDefaultSender()
        answer.append(defaultSender.toDict())

        contacts = Contact.all()
        contacts.filter('__key__ !=', defaultSender.key())
        
        for contact in contacts:
            answer.append(contact.toDict())
            
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(answer))
示例#3
0
    def set_data_for(self, group_id=None, search=None):

        if search:
            self.data = [("", tel.contact.name)
                          for tel in PhoneNumber.filter().group_by('contact')
                                            if search.contact == tel.contact]
        else:
            self.data = [("", contact.name) for contact in Contact.all()]

        if group_id:
            if group_id == ALL_CONTACTS:
                qs = ContactGroup.filter().group_by('contact')
            else:
                qs = ContactGroup.filter(group__id=group_id)
            self.data = [("", contact_gp.contact.name) for contact_gp in qs]