From da7de2c2a2163bec7846b98b3f1a7afeb5fd33cf Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Oct 2016 11:12:12 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=AD=E9=9A=90=E8=97=8F=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/_attachment_history_popub.html.erb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/files/_attachment_history_popub.html.erb b/app/views/files/_attachment_history_popub.html.erb index 02da5857f..fac1e2e36 100644 --- a/app/views/files/_attachment_history_popub.html.erb +++ b/app/views/files/_attachment_history_popub.html.erb @@ -14,7 +14,7 @@ <%= @attachment.downloads %> <%= @attachment.try(:quotes).to_i %> <%= format_time(@attachment.created_on) %> - + <% @attachment_histories.each do |history| %> @@ -24,14 +24,14 @@ <%= history.downloads %> <%= history.try(:quotes).to_i %> <%= format_time(history.created_on) %> - - <%= link_to( '删除资源', attachment_path(history.attachment, :history_id => history, :type => "history"), - :remote => true, - :data => {:confirm => l(:text_are_you_sure)}, - :method => :delete, - :class => "postOptionLink", + + <%#= link_to( '删除资源', attachment_path(history.attachment, :history_id => history, :type => "history"), +# :remote => true, +# :data => {:confirm => l(:text_are_you_sure)}, +# :method => :delete, +# :class => "postOptionLink", :class => "btn") if allow_to_delete_attachment(history) %> - + <% end %> From 50ba2fb04f4ed0285fc1e2c2b2bb11db76581746 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Oct 2016 11:31:15 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=92=8C=E6=B2=A1=E6=9C=89=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=88=A0=E9=99=A4=E9=99=84=E4=BB=B6=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 ++ app/views/files/_attachment_history_popub_delete.html.erb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 211b8da57..e7a5d3164 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -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 diff --git a/app/views/files/_attachment_history_popub_delete.html.erb b/app/views/files/_attachment_history_popub_delete.html.erb index 0f9624119..69c0d58b1 100644 --- a/app/views/files/_attachment_history_popub_delete.html.erb +++ b/app/views/files/_attachment_history_popub_delete.html.erb @@ -39,11 +39,11 @@
<% 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 %>
From 6dbb50f803699cc323fad05b689039a94db79b17 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Oct 2016 11:34:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=8F=98=E6=88=90=E6=89=8B=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_attachment_history_popub.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/files/_attachment_history_popub.html.erb b/app/views/files/_attachment_history_popub.html.erb index fac1e2e36..4ec1d3c55 100644 --- a/app/views/files/_attachment_history_popub.html.erb +++ b/app/views/files/_attachment_history_popub.html.erb @@ -54,6 +54,6 @@
取消 <%#= submit_tag '确定', :onclick => 'upload_attachment_version(event);', :onfocus => 'this.blur()', :id => 'upload_files_submit_btn', :class => 'btn btn-blue fr mr5' %> - 确定 + 确定
<% end %> From 8005958f032bc18144c9205d26bdb2ef0d406700 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Oct 2016 12:35:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachments/_show_attachment_history_delete.html.erb | 9 ++++++++- app/views/files/_attachment_history_popub.html.erb | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/views/attachments/_show_attachment_history_delete.html.erb b/app/views/attachments/_show_attachment_history_delete.html.erb index 489eaeed0..6a73f057a 100644 --- a/app/views/attachments/_show_attachment_history_delete.html.erb +++ b/app/views/attachments/_show_attachment_history_delete.html.erb @@ -1,6 +1,6 @@

删除资源

- +
@@ -9,3 +9,10 @@ <%= render :partial => "files/attachment_history_popub_delete" %>
+ + diff --git a/app/views/files/_attachment_history_popub.html.erb b/app/views/files/_attachment_history_popub.html.erb index 4ec1d3c55..c0a833030 100644 --- a/app/views/files/_attachment_history_popub.html.erb +++ b/app/views/files/_attachment_history_popub.html.erb @@ -52,8 +52,15 @@
- 取消 + 取消 <%#= submit_tag '确定', :onclick => 'upload_attachment_version(event);', :onfocus => 'this.blur()', :id => 'upload_files_submit_btn', :class => 'btn btn-blue fr mr5' %> 确定
<% end %> + +