mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 21:24:54 +08:00
Merge pull request #7965 from rekonder/aj_SCI_11157
Add activities for asset restore [SCI-11157]
This commit is contained in:
commit
cfefef8d01
3 changed files with 54 additions and 5 deletions
|
@ -416,6 +416,33 @@ class AssetsController < ApplicationController
|
|||
render_403 unless VersionedAttachments.enabled?
|
||||
|
||||
@asset.restore_file_version(params[:version].to_i)
|
||||
|
||||
message_items = {
|
||||
version: params[:version].to_i,
|
||||
file: @asset.file_name
|
||||
}
|
||||
|
||||
case @asset.parent
|
||||
when Step
|
||||
if @asset.parent.protocol.in_module?
|
||||
message_items.merge!({ my_module: @assoc.protocol.my_module.id, step: @asset.parent.id })
|
||||
log_restore_activity(:task_step_restore_asset_version, @assoc.protocol,
|
||||
@assoc.protocol.team, @assoc.my_module&.project, message_items)
|
||||
else
|
||||
message_items.merge!({ protocol: @assoc.protocol.id, step: @asset.parent.id })
|
||||
log_restore_activity(:protocol_step_restore_asset_version, @assoc.protocol,
|
||||
@assoc.protocol.team, nil, message_items)
|
||||
end
|
||||
when Result
|
||||
message_items.merge!({ result: @assoc.id, my_module: @assoc.my_module.id })
|
||||
log_restore_activity(:task_result_restore_asset_version, @assoc,
|
||||
@assoc.my_module.team, @assoc.my_module.project, message_items)
|
||||
when RepositoryCell
|
||||
message_items.merge!({ repository_column: @assoc.repository_column.id, repository: @repository.id })
|
||||
log_restore_activity(:repository_column_restore_asset_version, @repository,
|
||||
@repository.team, nil, message_items)
|
||||
end
|
||||
|
||||
render json: @asset.file.blob
|
||||
end
|
||||
|
||||
|
@ -494,4 +521,14 @@ class AssetsController < ApplicationController
|
|||
result: result.id
|
||||
}.merge(message_items))
|
||||
end
|
||||
|
||||
def log_restore_activity(type_of, subject, team, project = nil, message_items = {})
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: type_of,
|
||||
owner: current_user,
|
||||
subject: subject,
|
||||
team: team,
|
||||
project: project,
|
||||
message_items: message_items)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -516,25 +516,29 @@ class Extends
|
|||
storage_location_repository_row_created: 323,
|
||||
storage_location_repository_row_deleted: 324,
|
||||
storage_location_repository_row_moved: 325,
|
||||
container_storage_location_imported: 326
|
||||
container_storage_location_imported: 326,
|
||||
task_step_restore_asset_version: 327,
|
||||
task_result_restore_asset_version: 328,
|
||||
repository_column_restore_asset_version: 329,
|
||||
protocol_step_restore_asset_version: 330
|
||||
}
|
||||
|
||||
ACTIVITY_GROUPS = {
|
||||
projects: [*0..7, 32, 33, 34, 95, 108, 65, 109, *158..162, 241, 242, 243],
|
||||
task_results: [23, 26, 25, 42, 24, 40, 41, 99, 110, 122, 116, 128, *246..248, *257..273, *284..291, 301, 303, 306],
|
||||
task_results: [23, 26, 25, 42, 24, 40, 41, 99, 110, 122, 116, 128, *246..248, *257..273, *284..291, 301, 303, 306, 328],
|
||||
task: [8, 58, 9, 59, *10..14, 35, 36, 37, 53, 54, *60..63, 138, 139, 140, 64, 66, 106, 126, 120, 132,
|
||||
148, 166],
|
||||
task_protocol: [15, 22, 16, 18, 19, 20, 21, 17, 38, 39, 100, 111, 45, 46, 47, 121, 124, 115, 118, 127, 130, 137,
|
||||
184, 185, 188, 189, *192..203, 221, 222, 224, 225, 226, 236, *249..252, *274..278, 299, 302, 305],
|
||||
184, 185, 188, 189, *192..203, 221, 222, 224, 225, 226, 236, *249..252, *274..278, 299, 302, 305, 327],
|
||||
task_inventory: [55, 56, 146, 147, 183],
|
||||
experiment: [*27..31, 57, 141, 165],
|
||||
reports: [48, 50, 49, 163, 164],
|
||||
inventories: [70, 71, 105, 144, 145, 72, 73, 74, 102, 142, 143, 75, 76, 77,
|
||||
78, 96, 107, 113, 114, *133..136, 180, 181, 182, *292..298, 308],
|
||||
78, 96, 107, 113, 114, *133..136, 180, 181, 182, *292..298, 308, 329],
|
||||
protocol_repository: [80, 103, 89, 87, 79, 90, 91, 88, 85, 86, 84, 81, 82,
|
||||
83, 101, 112, 123, 125, 117, 119, 129, 131, 187, 186,
|
||||
190, 191, *204..215, 220, 223, 227, 228, 229, *230..235,
|
||||
*237..240, *253..256, *279..283, 300, 304, 307],
|
||||
*237..240, *253..256, *279..283, 300, 304, 307, 330],
|
||||
team: [92, 94, 93, 97, 104, 244, 245],
|
||||
label_templates: [*216..219],
|
||||
storage_locations: [*309..315],
|
||||
|
|
|
@ -340,6 +340,10 @@ en:
|
|||
storage_location_repository_row_deleted_html: "%{user} unassigned %{repository_row} from box %{storage_location} %{position}."
|
||||
storage_location_repository_row_moved_html: "%{user} moved item %{repository_row} from box %{storage_location_original} %{position_original} to box %{storage_location} %{position}."
|
||||
container_storage_location_imported_html: "%{user} assigned %{assigned_count} item(s) and unassigned %{unassigned_count} item(s) by import to %{storage_location}."
|
||||
task_step_restore_asset_version_html: "%{user} restored version <strong>%{version}</strong> of the file <strong>%{file}</strong> on protocol's step <strong>%{step}</strong> on task %{my_module}."
|
||||
task_result_restore_asset_version_html: "%{user} restored version <strong>%{version}</strong> of the file <strong>%{file}</strong> on result %{result} on task %{my_module}."
|
||||
repository_column_restore_asset_version_html: "%{user} restored version <strong>%{version}</strong> of the file <strong>%{file}</strong> in inventory column %{repository_column} in inventory %{repository}."
|
||||
protocol_step_restore_asset_version_html: "%{user} restored version <strong>%{version}</strong> of the file <strong>%{file}</strong> on Protocol's Template %{protocol} step <strong>%{step}</strong> in Protocol repository."
|
||||
activity_name:
|
||||
create_project: "Project created"
|
||||
rename_project: "Project renamed"
|
||||
|
@ -637,6 +641,10 @@ en:
|
|||
storage_location_repository_row_deleted: "Inventory item location unassigned"
|
||||
storage_location_repository_row_moved: "Inventory item location moved"
|
||||
container_storage_location_imported: "Box import"
|
||||
task_step_restore_asset_version: "Task step file version restored"
|
||||
task_result_restore_asset_version: "Result file version restored"
|
||||
repository_column_restore_asset_version: "Inventroy item file version restored"
|
||||
protocol_step_restore_asset_version: "Protocol step file version restored"
|
||||
activity_group:
|
||||
projects: "Projects"
|
||||
task_results: "Task results"
|
||||
|
|
Loading…
Reference in a new issue