From 319f286a65be012e32f063b77b8a0c8054ea2d83 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Mar 2016 12:19:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=B8=8B=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9A1.=E7=BB=84=E7=BB=87=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=9A=84=E5=BC=95=E7=94=A8=E8=AE=A1=E6=95=B0=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E5=A2=9E=E5=8A=A0=EF=BC=9B2.=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=A0=8F=E7=9B=AE=E4=B8=AD=EF=BC=8C=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AE=BD=E5=BA=A6=E4=B8=8D=E5=90=88=E9=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 18 +++++++++--------- app/views/files/_org_subfield_list.html.erb | 4 ++-- .../users/add_exist_file_to_course.js.erb | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1d328c1e9..49281f7b7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1693,17 +1693,17 @@ class UsersController < ApplicationController @flag = true if params[:send_id].present? send_id = params[:send_id] - ori = Attachment.find_by_id(send_id) + @ori = Attachment.find_by_id(send_id) course_ids = params[:course_ids] if course_ids.nil? @flag = false end unless course_ids.nil? course_ids.each do |id| - next if ori.blank? + next if @ori.blank? @exist = false Course.find(id).attachments.each do |att| #如果课程中包含该资源 - if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from + if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from att.created_on = Time.now att.save @exist = true @@ -1711,21 +1711,21 @@ class UsersController < ApplicationController end end next if @exist - attach_copied_obj = ori.copy - attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 + attach_copied_obj = @ori.copy + attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联 attach_copied_obj.container = Course.find(id) attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id attach_copied_obj.is_public = 0 - attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from + attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 4 end if attach_copied_obj.save # 更新引用次数 - quotes = ori.quotes.to_i + 1 - ori.update_attribute(:quotes, quotes) unless ori.nil? - ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + quotes = @ori.quotes.to_i + 1 + @ori.update_attribute(:quotes, quotes) unless @ori.nil? + @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) end @save_message = attach_copied_obj.errors.full_messages end diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index 38ff40ed3..641029bf2 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -8,7 +8,7 @@
- <%= link_to truncate(file.filename,length: 35, omission: '...'), + <%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'), download_named_attachment_path(file.id, file.filename), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> <%= file_preview_eye(file, class: 'preview') %> @@ -25,7 +25,7 @@ 上传类型:<%= file.tag_list[0] %> <% end %>

文件大小:<%= number_to_human_size(file.filesize) %>

-

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb index 57fe9d42d..c05a2ebd0 100644 --- a/app/views/users/add_exist_file_to_course.js.erb +++ b/app/views/users/add_exist_file_to_course.js.erb @@ -4,7 +4,8 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_ $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); +$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>"); hideModal(); -alert("发送成功") +alert("发送成功"); <% else%> <% end %> \ No newline at end of file