diff --git a/app/controllers/api/v1/connections_controller.rb b/app/controllers/api/v1/connections_controller.rb index a56d9d2f0..3c84ce2f8 100644 --- a/app/controllers/api/v1/connections_controller.rb +++ b/app/controllers/api/v1/connections_controller.rb @@ -7,7 +7,7 @@ module Api before_action :load_project before_action :load_experiment before_action :load_connections - before_action :load_connection, only: :show + before_action :load_connection, only: %i(show destroy) before_action :check_manage_permissions, except: %i(index show) def index @@ -21,7 +21,7 @@ module Api def show render jsonapi: @connection, serializer: ConnectionSerializer, - include: %i(to from) + include: include_params end def create @@ -29,10 +29,12 @@ module Api render jsonapi: connection, serializer: ConnectionSerializer, - include: %i(to from) + include: include_params end def destroy + raise PermissionError.new(Connection, :destroy) unless can_manage_experiment?(@experiment) + @connection.destroy! render body: nil end diff --git a/app/serializers/api/v1/connection_serializer.rb b/app/serializers/api/v1/connection_serializer.rb index 143f440e9..e30c3c441 100644 --- a/app/serializers/api/v1/connection_serializer.rb +++ b/app/serializers/api/v1/connection_serializer.rb @@ -5,10 +5,10 @@ module Api class ConnectionSerializer < ActiveModel::Serializer type :connections attributes :id - belongs_to :from, key: :input_task, + belongs_to :from, key: :from, serializer: TaskSerializer, class_name: 'MyModule' - belongs_to :to, key: :output_task, + belongs_to :to, key: :to, serializer: TaskSerializer, class_name: 'MyModule' end