Merge pull request #8719 from okriuchykhin/ok_SCI_12174

Fix listing of protocol templates [SCI-12174]
This commit is contained in:
Alex Kriuchykhin 2025-07-29 12:51:06 +02:00 committed by GitHub
commit 45f7cdade2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View file

@ -11,13 +11,11 @@ module Api
end
def index
protocol_templates =
timestamps_filter(
Protocol.latest_available_versions(@team)
)
.readable_by_user(current_user, @team)
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
protocol_templates = timestamps_filter(Protocol.latest_available_versions(@team))
# Team owners see all protocol templates in the team
protocol_templates = protocol_templates.readable_by_user(current_user, @team) unless can_manage_team?(@team)
protocol_templates = protocol_templates.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: protocol_templates,
each_serializer: ProtocolTemplateSerializer, rte_rendering: render_rte?, team: @team

View file

@ -85,10 +85,11 @@ class ProtocolsController < ApplicationController
else
current_team.repository_protocols.readable_by_user(current_user, current_team)
end
render json: Lists::ProtocolsService.new(protocols, params).call,
protocols_list = Lists::ProtocolsService.new(protocols, params).call
render json: protocols_list,
each_serializer: Lists::ProtocolSerializer,
user: current_user,
meta: pagination_dict(protocols)
meta: pagination_dict(protocols_list)
end
format.html do
render 'index'