Update front end permission check for version comment [SCI-8160]

This commit is contained in:
Anton 2023-03-24 10:55:17 +01:00
parent e065098082
commit 9818e41353
4 changed files with 3 additions and 20 deletions

View file

@ -43,7 +43,6 @@ class ProtocolsController < ApplicationController
update_from_parent_modal
delete_steps
)
before_action :check_manage_all_in_repository_permissions, only: :make_private
before_action :check_restore_all_in_repository_permissions, only: :restore
before_action :check_archive_all_in_repository_permissions, only: :archive
before_action :check_load_from_repository_views_permissions, only: %i(
@ -1011,7 +1010,7 @@ class ProtocolsController < ApplicationController
@protocol = Protocol.find_by(id: params[:id])
render_403 unless @protocol.present? &&
(can_manage_protocol_in_module?(@protocol) ||
can_manage_protocol_in_repository?(@protocol))
can_manage_protocol_draft_in_repository?(@protocol))
end
def check_save_as_draft_permissions
@ -1025,16 +1024,6 @@ class ProtocolsController < ApplicationController
can_delete_protocol_draft_in_repository?(@protocol)
end
def check_manage_all_in_repository_permissions
@protocols = Protocol.where(id: params[:protocol_ids])
@protocols.find_each do |protocol|
unless can_manage_protocol_in_repository?(protocol)
respond_to { |f| f.json { render json: {}, status: :unauthorized } }
break
end
end
end
def check_archive_all_in_repository_permissions
@protocols = Protocol.where(id: params[:protocol_ids])
@protocols.find_each do |protocol|

View file

@ -8,12 +8,6 @@ class ProtocolsDatatable < CustomDatatable
PREFIXED_ID_SQL = "('#{Protocol::ID_PREFIX}' || COALESCE(\"protocols\".\"parent_id\", \"protocols\".\"id\"))"
def_delegator :@view, :can_read_protocol_in_repository?
def_delegator :@view, :can_manage_protocol_in_repository?
def_delegator :@view, :edit_protocol_path
def_delegator :@view, :can_restore_protocol_in_repository?
def_delegator :@view, :can_clone_protocol_in_repository?
def_delegator :@view, :clone_protocol_path
def_delegator :@view, :linked_children_protocol_path
def_delegator :@view, :protocol_path

View file

@ -44,7 +44,7 @@
<% end %>
</div>
<div class="protocol-version-comment">
<% if can_publish_protocol_in_repository?(draft) %>
<% if can_manage_protocol_draft_in_repository?(draft) %>
<div
class="protocol-comment-container inline-init-handler"
data-field-to-update="version_comment"

View file

@ -12,7 +12,7 @@
step.protocol.team,
text %>
<% end %>
<% elsif can_manage_protocol_in_repository?(step.protocol) %>
<% elsif can_read_protocol_in_repository?(step.protocol) %>
<%= route_to_other_team protocol_path(step.protocol),
step.protocol.team,
text %>