mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Fix keys in connection serializer, fix destroy method [SCI-6087] (#3677)
This commit is contained in:
parent
ebfd2f7924
commit
ee8cb033fa
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue