diff --git a/app/controllers/external_protocols_controller.rb b/app/controllers/external_protocols_controller.rb
index 7551c7989..ddcf81146 100644
--- a/app/controllers/external_protocols_controller.rb
+++ b/app/controllers/external_protocols_controller.rb
@@ -83,17 +83,13 @@ class ExternalProtocolsController < ApplicationController
service_call = ProtocolImporters::ImportProtocolService.call(
protocol_params: create_protocol_params,
steps_params_json: create_steps_params[:steps],
- user_id: current_user.id,
- team_id: @team.id
+ user: current_user,
+ team: @team
)
if service_call.succeed?
- protocol_type = service_call.protocol.in_repository_public? ? 'public' : 'private'
- message = t('protocols.index.external_protocols.import.success_flash',
- name: service_call.protocol.name,
- type: t("protocols.index.external_protocols.import.#{protocol_type}"))
- render json: { protocol: service_call.protocol,
- message: message }
+ message = t('protocols.index.protocolsio.import.success_flash', name: service_call.protocol.name)
+ render json: { protocol: service_call.protocol, message: message }
else
render json: { validation_errors: service_call.errors }, status: :bad_request
end
@@ -120,7 +116,10 @@ class ExternalProtocolsController < ApplicationController
end
def create_protocol_params
- params.require(:protocol).permit(:name, :authors, :published_on, :protocol_type, :description).except(:steps)
+ params
+ .require(:protocol)
+ .permit(:name, :authors, :published_on, :protocol_type, :description, :visibility, :default_public_user_role_id)
+ .except(:steps)
end
def create_steps_params
diff --git a/app/services/protocol_importers/import_protocol_service.rb b/app/services/protocol_importers/import_protocol_service.rb
index 248ce6112..967bfb644 100644
--- a/app/services/protocol_importers/import_protocol_service.rb
+++ b/app/services/protocol_importers/import_protocol_service.rb
@@ -6,9 +6,9 @@ module ProtocolImporters
attr_reader :errors, :protocol
- def initialize(protocol_params:, steps_params_json:, team_id:, user_id:)
- @user = User.find_by_id user_id
- @team = Team.find_by_id team_id
+ def initialize(protocol_params:, steps_params_json:, team:, user:)
+ @user = user
+ @team = team
@protocol_params = protocol_params
@steps_params = JSON.parse(steps_params_json)
@errors = {}
diff --git a/app/utilities/protocol_importers/protocol_intermediate_object.rb b/app/utilities/protocol_importers/protocol_intermediate_object.rb
index ecddee038..e6c71c442 100644
--- a/app/utilities/protocol_importers/protocol_intermediate_object.rb
+++ b/app/utilities/protocol_importers/protocol_intermediate_object.rb
@@ -43,7 +43,7 @@ module ProtocolImporters
def protocol_attributes
{
- protocol_type: :in_repository_public,
+ protocol_type: :in_repository_draft,
added_by: @user,
team: @team,
name: @normalized_protocol_data[:name],
diff --git a/app/views/protocol_importers/_preview_modal_footer.html.erb b/app/views/protocol_importers/_preview_modal_footer.html.erb
index 426d69436..e7f5734e4 100644
--- a/app/views/protocol_importers/_preview_modal_footer.html.erb
+++ b/app/views/protocol_importers/_preview_modal_footer.html.erb
@@ -1,3 +1,3 @@
-
-
+
+
diff --git a/spec/services/protocol_importers/import_protocol_service_spec.rb b/spec/services/protocol_importers/import_protocol_service_spec.rb
index 24b696803..a94322aa5 100644
--- a/spec/services/protocol_importers/import_protocol_service_spec.rb
+++ b/spec/services/protocol_importers/import_protocol_service_spec.rb
@@ -15,7 +15,7 @@ describe ProtocolImporters::ImportProtocolService do
let(:service_call) do
ProtocolImporters::ImportProtocolService
- .call(protocol_params: protocol_params, steps_params_json: steps_params, user_id: user.id, team_id: team.id)
+ .call(protocol_params: protocol_params, steps_params_json: steps_params, user: user, team: team)
end
context 'when have invalid arguments' do
@@ -33,7 +33,7 @@ describe ProtocolImporters::ImportProtocolService do
s = ProtocolImporters::ImportProtocolService.call(protocol_params: protocol_params,
steps_params_json: steps_invalid_params,
- user_id: user.id, team_id: team.id)
+ user: user, team: team)
expect(s.protocol).to be_invalid
end
end