diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb
index cb5a436cb..7cab925e7 100644
--- a/app/controllers/protocols_controller.rb
+++ b/app/controllers/protocols_controller.rb
@@ -591,7 +591,7 @@ class ProtocolsController < ApplicationController
message_items: {
protocol: protocol.id
})
-
+ generate_import_protocol_notification(current_user, protocol)
format.json do
render json: { status: :ok }, status: :ok
end
@@ -766,20 +766,7 @@ class ProtocolsController < ApplicationController
end
z_output_stream.rewind
- protocol_name = get_protocol_name(@protocols[0])
-
- # Now generate filename of the archive and send file to user
- if @protocols.count == 1
- # Try to construct an OS-safe file name
- file_name = 'protocol.eln'
- unless protocol_name.nil?
- escaped_name = protocol_name.gsub(/[^0-9a-zA-Z\-.,_]/i, '_')
- .downcase[0..Constants::NAME_MAX_LENGTH]
- file_name = escaped_name + '.eln' unless escaped_name.blank?
- end
- elsif @protocols.length > 1
- file_name = 'protocols.eln'
- end
+ file_name = export_protocol_file_name(@protocols)
@protocols.each do |protocol|
if params[:my_module_id]
@@ -942,6 +929,46 @@ class ProtocolsController < ApplicationController
end
end
+ def generate_import_protocol_notification(user, protocol)
+ protocol_download_link = "" \
+ "#{export_protocol_file_name([protocol])}"
+
+ notification = Notification.create(
+ type_of: :deliver,
+ title: I18n.t('protocols.import_export.import_protocol_notification.title', link: protocol_download_link),
+ message: "#{I18n.t('protocols.import_export.import_protocol_notification.message')} " \
+ "#{protocol.name}"
+ )
+
+ UserNotification.create(notification: notification, user: user)
+ end
+
+ def export_protocol_file_name(protocols)
+ protocol_name = get_protocol_name(protocols[0])
+
+ if protocols.count == 1
+ file_name = 'protocol.eln'
+ unless protocol_name.nil?
+ escaped_name = protocol_name.gsub(/[^0-9a-zA-Z\-.,_]/i, '_')
+ .downcase[0..Constants::NAME_MAX_LENGTH]
+ file_name = escaped_name + '.eln' unless escaped_name.blank?
+ end
+ elsif protocols.length > 1
+ file_name = 'protocols.eln'
+ end
+ file_name
+ end
+
def valid_protocol_json(json)
JSON.parse(json)
return true
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a255e8235..dff1c6dc8 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2775,6 +2775,9 @@ en:
import_to_team_protocols_label: "Import to Team Protocols"
import_to_private_protocols_label: "Import to My Protocols"
import_protocols_label: "Import"
+ import_protocol_notification:
+ title: "The import process has been successfully completed. You can download original file here: %{link}"
+ message: "Protocol template:"
export:
export_results:
title: "Export results"