replace user_schema with serialize method on user model

this is so that we can filter out inactive organisations and services

note: can't remove user schema completely, as we still use it in
POST /user to create new users
This commit is contained in:
Leo Hemsted
2018-03-06 17:47:29 +00:00
parent c6c56f9cdc
commit efec57db01
6 changed files with 87 additions and 39 deletions

View File

@@ -20,7 +20,6 @@ from app.organisation.organisation_schema import (
post_link_service_to_organisation_schema,
)
from app.schema_validation import validate
from app.schemas import user_schema
organisation_blueprint = Blueprint('organisation', __name__)
register_errors(organisation_blueprint)
@@ -98,15 +97,13 @@ def get_organisation_services(organisation_id):
@organisation_blueprint.route('/<uuid:organisation_id>/users/<uuid:user_id>', methods=['POST'])
def add_user_to_organisation(organisation_id, user_id):
new_org_user = dao_add_user_to_organisation(organisation_id, user_id)
return jsonify(data=user_schema.dump(new_org_user).data), 200
return jsonify(data=new_org_user.serialize())
@organisation_blueprint.route('/<uuid:organisation_id>/users', methods=['GET'])
def get_organisation_users(organisation_id):
org_users = dao_get_users_for_organisation(organisation_id)
result = user_schema.dump(org_users, many=True)
return jsonify(data=result.data)
return jsonify(data=[x.serialize() for x in org_users])
@organisation_blueprint.route('/unique', methods=["GET"])