mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 16:45:18 +08:00
Prevent archive of locked result asset
This commit is contained in:
parent
f727289935
commit
03567d6208
5 changed files with 27 additions and 8 deletions
|
@ -118,6 +118,16 @@ class ResultAssetsController < ApplicationController
|
|||
module: @my_module.name)
|
||||
|
||||
if @result.archived_changed?(from: false, to: true)
|
||||
if previous_asset.locked?
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:error] = t('result_assets.archive.error_flash')
|
||||
redirect_to results_my_module_path(@my_module)
|
||||
return
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
saved = @result.archive(current_user)
|
||||
success_flash = t("result_assets.archive.success_flash",
|
||||
module: @my_module.name)
|
||||
|
|
|
@ -39,6 +39,14 @@ module ResultsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def result_unlocked?(result)
|
||||
if result.is_asset
|
||||
!result.asset.locked?
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def result_path_of_type(result)
|
||||
if result.is_asset
|
||||
result_asset_path(result.result_asset)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<span class="glyphicon glyphicon-edit"></span>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if can_archive_result(result) and not result.archived %>
|
||||
<% if can_archive_result(result) && !result.archived && result_unlocked?(result) %>
|
||||
<a href="#" class="btn btn-link form-submit-link" data-submit-form="result-archive-form-<%= result.id %>" data-confirm-form="<%= t('my_modules.results.archive_confirm') %>" title="<%= t'my_modules.results.options.archive_title' %>">
|
||||
<span class="glyphicon glyphicon-briefcase"></span>
|
||||
</a>
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
<%= image_tag(preview_asset_path result.asset) if result.asset.is_image? %>
|
||||
<p><%= truncate(result.asset.file_file_name, length: 50) %></p>
|
||||
<% end %>
|
||||
<% if result.asset.can_perform_action("view") %>
|
||||
<%= link_to "View", view_asset_url(id: result.asset) %>
|
||||
<% end %>
|
||||
<% if can_edit_result_asset_in_module(result.my_module) &&
|
||||
result.asset.can_perform_action("edit") %>
|
||||
<%= link_to "Edit", edit_asset_url(id: result.asset) %>
|
||||
<% end %>
|
||||
<% if result.asset.can_perform_action("view") %>
|
||||
<%= link_to "View", view_asset_url(id: result.asset) %>
|
||||
<% end %>
|
||||
<% if can_edit_result_asset_in_module(result.my_module) &&
|
||||
result.asset.can_perform_action("edit") %>
|
||||
<%= link_to "Edit", edit_asset_url(id: result.asset) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= image_tag(preview_asset_path result.asset) if result.asset.is_image? %>
|
||||
<p><%= result.asset.file_file_name %></p>
|
||||
|
|
|
@ -844,6 +844,7 @@ en:
|
|||
success_flash: "Successfully updated file result in task <strong>%{module}</strong>"
|
||||
archive:
|
||||
success_flash: "Successfully archived file result in task <strong>%{module}</strong>"
|
||||
error_flash: "Couldn't archive file result. Someone is editing that file."
|
||||
destroy:
|
||||
success_flash: "File result successfully deleted."
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue