def handshake(): global stored_person incoming_json = request.get_json() print incoming_json target_id = incoming_json['target_system_id'] user_id = incoming_json['username'] # find our user data and put it in the bucket try: u = User.objects(pk=user_id)[0] p = Person.objects(pk=user_id)[0] print u print p stored_person = p bucket.put(target_id, user_id, p) except ValidationError: return jsonify({ 'acknowledgement': False, 'message': 'Could not find user with ID %s' % user_id }) return jsonify({ 'acknowledgement': True, 'messsage': 'Sending data to target %s' % target_id })
def handshake(): global stored_person incoming_json = request.get_json() print incoming_json target_id = incoming_json['target_system_id'] user_id = incoming_json['username'] # find our user data and put it in the bucket try: u = User.objects(pk=user_id)[0] p = Person.objects(pk=user_id)[0] print u print p stored_person = p bucket.put(target_id, user_id, p) except ValidationError: return jsonify({'acknowledgement': False, 'message': 'Could not find user with ID %s' % user_id}) return jsonify({'acknowledgement': True, 'messsage': 'Sending data to target %s' % target_id})
return o if __name__ == '__main__': print 'Simplixity Data Insertion' client = MongoClient() db = client['simplixity'] people = make_fake_people(10) person = db.person user = db.user organization = db.organization person.remove(None) user.remove(None) for p in people: policy = make_fake_policy() policy.save() o = make_fake_org() o.save() u = User(organ_donor=True) u.employer = o u.person = p u.conditions = [make_fake_condition()] u.policies = [policy] p.save() u.save(cascade=True)
def get_single_user(user_id): return User.objects(pk=user_id).to_json()
client = MongoClient() db = client['simplixity'] people = make_fake_people(10) person = db.person user = db.user organization = db.organization person.remove(None) user.remove(None) for p in people: policy = make_fake_policy() policy.save() o = make_fake_org() o.save() u = User(organ_donor = True) u.employer = o u.person = p u.conditions = [make_fake_condition()] u.policies = [policy] p.save() u.save(cascade=True)