mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 16:31:22 +08:00
Fix protocol dropdown options for private protocol [SCI-7983] (#5337)
This commit is contained in:
parent
342b581259
commit
c4a0ebeadf
2 changed files with 15 additions and 5 deletions
|
|
@ -27,8 +27,6 @@ class ProtocolsController < ApplicationController
|
||||||
protocolsio_index
|
protocolsio_index
|
||||||
datatable
|
datatable
|
||||||
)
|
)
|
||||||
# For update_from_parent and update_from_parent_modal we don't need to check
|
|
||||||
# read permission for the parent protocol
|
|
||||||
before_action :check_manage_permissions, only: %i(
|
before_action :check_manage_permissions, only: %i(
|
||||||
update_keywords
|
update_keywords
|
||||||
update_description
|
update_description
|
||||||
|
|
@ -37,11 +35,14 @@ class ProtocolsController < ApplicationController
|
||||||
update_authors
|
update_authors
|
||||||
unlink
|
unlink
|
||||||
unlink_modal
|
unlink_modal
|
||||||
|
delete_steps
|
||||||
|
)
|
||||||
|
|
||||||
|
before_action :check_manage_with_read_protocol_permissions, only: %i(
|
||||||
revert
|
revert
|
||||||
revert_modal
|
revert_modal
|
||||||
update_from_parent
|
update_from_parent
|
||||||
update_from_parent_modal
|
update_from_parent_modal
|
||||||
delete_steps
|
|
||||||
)
|
)
|
||||||
before_action :check_restore_all_in_repository_permissions, only: :restore
|
before_action :check_restore_all_in_repository_permissions, only: :restore
|
||||||
before_action :check_archive_all_in_repository_permissions, only: :archive
|
before_action :check_archive_all_in_repository_permissions, only: :archive
|
||||||
|
|
@ -1010,6 +1011,13 @@ class ProtocolsController < ApplicationController
|
||||||
can_manage_protocol_draft_in_repository?(@protocol))
|
can_manage_protocol_draft_in_repository?(@protocol))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_manage_with_read_protocol_permissions
|
||||||
|
@protocol = Protocol.find_by(id: params[:id])
|
||||||
|
render_403 unless @protocol.present? && @protocol.parent.present? &&
|
||||||
|
(can_manage_protocol_in_module?(@protocol) &&
|
||||||
|
can_read_protocol_in_repository?(@protocol.parent))
|
||||||
|
end
|
||||||
|
|
||||||
def check_save_as_draft_permissions
|
def check_save_as_draft_permissions
|
||||||
@protocol = Protocol.find_by(id: params[:id])
|
@protocol = Protocol.find_by(id: params[:id])
|
||||||
render_403 unless @protocol.present? && can_save_protocol_version_as_draft?(@protocol)
|
render_403 unless @protocol.present? && can_save_protocol_version_as_draft?(@protocol)
|
||||||
|
|
|
||||||
|
|
@ -174,14 +174,16 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
def revert_protocol_url
|
def revert_protocol_url
|
||||||
return unless can_manage_protocol_in_module?(object) && object.linked? &&
|
return unless can_manage_protocol_in_module?(object) && object.linked? &&
|
||||||
object.parent.active? && object.newer_than_parent?
|
object.parent.active? && object.newer_than_parent? &&
|
||||||
|
can_read_protocol_in_repository?(object.parent)
|
||||||
|
|
||||||
revert_modal_protocol_path(object, format: :json)
|
revert_modal_protocol_path(object, format: :json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_protocol_url
|
def update_protocol_url
|
||||||
return unless can_manage_protocol_in_module?(object) && object.linked? &&
|
return unless can_manage_protocol_in_module?(object) && object.linked? &&
|
||||||
object.parent.active? && object.parent_newer?
|
object.parent.active? && object.parent_newer? &&
|
||||||
|
can_read_protocol_in_repository?(object.parent)
|
||||||
|
|
||||||
update_from_parent_modal_protocol_path(object, format: :json)
|
update_from_parent_modal_protocol_path(object, format: :json)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue