2018-09-07 21:19:20 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class ProtocolsController < BaseController
|
2020-08-07 22:51:57 +08:00
|
|
|
include Api::V1::ExtraParams
|
|
|
|
|
|
|
|
before_action :load_team, :load_project, :load_experiment, :load_task
|
|
|
|
before_action only: :show do
|
|
|
|
load_protocol(:id)
|
|
|
|
end
|
2018-09-07 21:19:20 +08:00
|
|
|
|
|
|
|
def index
|
2018-10-07 17:29:56 +08:00
|
|
|
protocols = @task.protocols
|
2018-10-23 23:52:48 +08:00
|
|
|
.page(params.dig(:page, :number))
|
|
|
|
.per(params.dig(:page, :size))
|
2018-09-07 21:19:20 +08:00
|
|
|
render jsonapi: protocols,
|
2020-08-07 22:51:57 +08:00
|
|
|
each_serializer: ProtocolSerializer, rte_rendering: render_rte?, team: @team
|
2018-09-07 21:19:20 +08:00
|
|
|
end
|
|
|
|
|
2020-08-07 22:51:57 +08:00
|
|
|
def show
|
|
|
|
render jsonapi: @protocol, serializer: ProtocolSerializer,
|
|
|
|
include: include_params,
|
|
|
|
rte_rendering: render_rte?,
|
|
|
|
team: @team
|
2018-09-07 21:19:20 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|