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 end
def index def index
protocol_templates = protocol_templates = timestamps_filter(Protocol.latest_available_versions(@team))
timestamps_filter( # Team owners see all protocol templates in the team
Protocol.latest_available_versions(@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))
.readable_by_user(current_user, @team) .per(params.dig(:page, :size))
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: protocol_templates, render jsonapi: protocol_templates,
each_serializer: ProtocolTemplateSerializer, rte_rendering: render_rte?, team: @team each_serializer: ProtocolTemplateSerializer, rte_rendering: render_rte?, team: @team

View file

@ -85,10 +85,11 @@ class ProtocolsController < ApplicationController
else else
current_team.repository_protocols.readable_by_user(current_user, current_team) current_team.repository_protocols.readable_by_user(current_user, current_team)
end 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, each_serializer: Lists::ProtocolSerializer,
user: current_user, user: current_user,
meta: pagination_dict(protocols) meta: pagination_dict(protocols_list)
end end
format.html do format.html do
render 'index' render 'index'