Review changes

This commit is contained in:
Zanz2 2018-09-13 09:25:16 +02:00
parent ae3c19ced5
commit 1159ce519c
3 changed files with 13 additions and 5 deletions

View file

@ -6,7 +6,7 @@ module Api
before_action :load_team
before_action :load_project
before_action :load_experiment
before_action :load_task_groups, only: :show
before_action :load_task_group, only: :show
def index
my_module_groups = @experiment.my_module_groups
@ -42,11 +42,10 @@ module Api
)
end
def load_task_groups
def load_task_group
@my_module_group = @experiment.my_module_groups.find(
params.require(:id)
)
render jsonapi: {}, status: :not_found if @my_module_group.nil?
end
end
end

View file

@ -5,6 +5,15 @@ module Api
class ConnectionSerializer < ActiveModel::Serializer
type :connections
attributes :id, :input_id, :output_id
has_one :input_task, serializer: MyModuleSerializer
has_one :output_task, serializer: MyModuleSerializer
def input_task
MyModule.find(object.input_id)
end
def output_task
MyModule.find(object.output_id)
end
end
end
end

View file

@ -4,8 +4,8 @@ module Api
module V1
class MyModuleSerializer < ActiveModel::Serializer
type :tasks
attributes :id, :name, :due_date, :description,
:my_module_group_id, :nr_of_assigned_samples, :state
attributes :id, :name, :due_date, :description, :state
attribute :my_module_group_id, key: :task_group_id
belongs_to :experiment, serializer: ExperimentSerializer
end
end