多个历史版本和没有历史版本删除附件提醒

This commit is contained in:
huang 2016-10-15 11:31:15 +08:00
parent da7de2c2a2
commit 50ba2fb04f
2 changed files with 5 additions and 3 deletions

View File

@ -348,6 +348,7 @@ class AttachmentsController < ApplicationController
@is_history_delete = true
@is_history_destroy = false
@attachment_histories = @attachment.attachment_histories
@attachment_histories_count = @attachment_histories.count
rescue Exception => e
puts e
end
@ -667,6 +668,7 @@ class AttachmentsController < ApplicationController
def attachment_versions_delete
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
@attachment_histories_count = @attachment_histories.count
respond_to do |format|
format.js
end

View File

@ -39,11 +39,11 @@
</table>
<div>
<% if @attachment.container_type == "Project" %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history_delete => true), :data => {:confirm => l(:text_history_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (is_project_manager?(User.current.id, @attachment.container_id) || User.current.id == @attachment.author_id || User.current.admin?) %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history_delete => true), :data => {:confirm => @attachment_histories_count.to_i > 0 ? l(:text_history_are_you_sure) : l(:text_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (is_project_manager?(User.current.id, @attachment.container_id) || User.current.id == @attachment.author_id || User.current.admin?) %>
<% elsif @attachment.container_type == "Course" %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history_delete => true), :data => {:confirm => l(:text_history_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (User.current.allowed_to?(:as_teacher, @attachment.container) || User.current.id == @attachment.author_id || User.current.admin?) %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history_delete => true), :data => {:confirm => @attachment_histories_count.to_i > 0 ? l(:text_history_are_you_sure) : l(:text_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (User.current.allowed_to?(:as_teacher, @attachment.container) || User.current.id == @attachment.author_id || User.current.admin?) %>
<% elsif @attachment.container_type == "OrgSubfield" %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history => true), :data => {:confirm => l(:text_history_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (User.current.id == @attachment.author_id || User.current.admin_of_org?(@attachment) || User.current.admin?) %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history => true), :data => {:confirm => @attachment_histories_count.to_i > 0 ? l(:text_history_are_you_sure) : l(:text_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (User.current.id == @attachment.author_id || User.current.admin_of_org?(@attachment) || User.current.admin?) %>
<% end %>
</div>