diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb
index 905b2f256..62e31231a 100644
--- a/app/controllers/assets_controller.rb
+++ b/app/controllers/assets_controller.rb
@@ -118,8 +118,13 @@ class AssetsController < ApplicationController
object_to_update = @asset.result_asset
object_to_update.update!(result: target)
+ type_of = {
+ 'marvinjs' => :move_chemical_structure_on_result,
+ 'gene_sequence' => :sequence_on_result_moved
+ }.fetch(@asset.file.metadata[:asset_type], :result_file_moved)
+
log_result_activity(
- @asset.file.metadata[:asset_type] == 'marvinjs' ? :move_chemical_structure_on_result : :result_file_moved,
+ type_of,
@assoc,
file: @asset.file_name,
user: current_user.id,
@@ -296,7 +301,7 @@ class AssetsController < ApplicationController
end
when Result
log_result_activity(
- :result_file_deleted,
+ @asset.file.metadata[:asset_type] == 'gene_sequence' ? :sequence_on_result_deleted : :result_file_deleted,
@assoc,
file: @asset.file_name
)
diff --git a/app/controllers/gene_sequence_assets_controller.rb b/app/controllers/gene_sequence_assets_controller.rb
index ba17af824..294cc6e11 100644
--- a/app/controllers/gene_sequence_assets_controller.rb
+++ b/app/controllers/gene_sequence_assets_controller.rb
@@ -25,13 +25,37 @@ class GeneSequenceAssetsController < ApplicationController
def create
save_asset!
- log_activity('sequence_asset_added')
+
+ case @parent
+ when Step
+ log_activity('sequence_asset_added')
+ when Result
+ log_result_activity(
+ :sequence_on_result_added,
+ @parent,
+ file: @asset.file_name,
+ user: current_user.id
+ )
+ end
+
head :ok
end
def update
save_asset!
- log_activity('sequence_asset_edit_finished')
+
+ case @parent
+ when Step
+ log_activity('sequence_asset_edit_finished')
+ when Result
+ log_result_activity(
+ :sequence_on_result_edited,
+ @parent,
+ file: @asset.file_name,
+ user: current_user.id
+ )
+ end
+
head :ok
end
@@ -171,4 +195,16 @@ class GeneSequenceAssetsController < ApplicationController
project: project
)
end
+
+ def log_result_activity(type_of, result, message_items)
+ Activities::CreateActivityService
+ .call(activity_type: type_of,
+ owner: current_user,
+ subject: result,
+ team: result.my_module.team,
+ project: result.my_module.project,
+ message_items: {
+ result: result.id
+ }.merge(message_items))
+ end
end
diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb
index 7d1523c28..88aba27c2 100644
--- a/config/initializers/extends.rb
+++ b/config/initializers/extends.rb
@@ -488,7 +488,10 @@ class Extends
result_file_moved: 284,
result_text_moved: 285,
result_table_moved: 286,
- move_chemical_structure_on_result: 287
+ sequence_on_result_added: 287,
+ sequence_on_result_edited: 288,
+ sequence_on_result_deleted: 289,
+ sequence_on_result_moved: 290
}
ACTIVITY_GROUPS = {
@@ -497,7 +500,8 @@ class Extends
task: [8, 58, 9, 59, *10..14, 35, 36, 37, 53, 54, *60..63, 138, 139, 140, 64, 66, 106, 126, 120, 132,
*146..148, 166, 246, 247, 248],
task_protocol: [15, 22, 16, 18, 19, 20, 21, 17, 38, 39, 100, 111, 45, 46, 47, 121, 124, 115, 118, 127, 130, 137,
- 217, 168, 171, 177, 184, 185, 188, 189, *192..203, 222, 224, 225, 226, 236, *249..252, *274..278],
+ 217, 168, 171, 177, 184, 185, 188, 189, *192..203, 222, 224, 225, 226, 236, *249..252, *274..278,
+ *287..290],
task_inventory: [55, 56, 146, 147, 183],
experiment: [*27..31, 57, 141, 165],
reports: [48, 50, 49, 163, 164],
diff --git a/config/locales/global_activities/en.yml b/config/locales/global_activities/en.yml
index 9c26942df..2b2932ee3 100644
--- a/config/locales/global_activities/en.yml
+++ b/config/locales/global_activities/en.yml
@@ -71,6 +71,10 @@ en:
result_restored_html: "%{user} restored result %{result} from archive."
result_file_added_html: "%{user} added file %{file} to result %{result}."
result_file_deleted_html: "%{user} deleted file %{file} in result %{result}."
+ sequence_on_result_added_html: "%{user} created sequence %{file} on result %{result}."
+ sequence_on_result_edited_html: "%{user} edited sequence %{file} on result %{result}."
+ sequence_on_result_deleted_html: "%{user} deleted sequence %{file} on result %{result}."
+ sequence_on_result_moved_html: "%{user} moved sequence %{file} from result %{result_original} to result %{result_destination}."
result_text_added_html: "%{user} created text %{text_name} in result %{result}."
result_text_edited_html: "%{user} edited text %{text_name} in result %{result}."
result_text_deleted_html: "%{user} deleted text %{text_name} in result %{result}."