def search_org(): org_id = org_model.id_from('name', request.args.get('term')) org = org_model.get(org_id) if not permission_model.permitted(g.user, org_id, PermissionTags.VIEW): org = {} return Response(json.dumps(org), content_type='application/json')
def create_user(): user = user_model.create({ 'email': request.form['email'], 'name': request.form['name'], 'password': request.form['password'], }) for example_org_name in settings.EXAMPLE_ORGS: org_id = org_model.id_from('name', example_org_name) if org_id: org_model.add_user(org_id, user['id']) # Add user to waiting list orgs waiting_list = user_model.get_waiting_list_for_email(user['email']) if waiting_list: added_orgs = [] for entry in waiting_list: org_id, role = entry.split('_') org_model.add_user(org_id, user['id'], role=role) user_model.remove_from_waiting_list(user['email'], org_id) else: events.mediator('signed_up', email=user['email'], name=user['name']) return Response(json.dumps(user), status=201, content_type='application/json')