#1387修复课程--资源库-关联资源查询出来的结果是整个项目中资源的集合的BUG

course_group
sw 11 years ago
parent 56ac9222ef
commit 3a48034fca

@ -143,16 +143,19 @@ module AttachmentsHelper
params[:q] ||= "" params[:q] ||= ""
filename_condition = params[:q].strip filename_condition = params[:q].strip
attachAll = Attachment.scoped #attachAll = Attachment.where("author_id = #{User.current.id}")
#
# 除去当前课程的所有资源 ## 除去当前课程的所有资源
nobelong_attach = Attachment.where("!(container_type = '#{course.class}' and container_id = #{course.id})") unless course.blank? #nobelong_attach =
# 搜索域确定 # 搜索域确定
domain = course.nil? ? attachAll : nobelong_attach course.nil? ?
domain=Attachment.where("author_id = #{User.current.id}")
:
domain=Attachment.where("author_id = #{User.current.id} and container_type = 'Course' and container_id <> #{course.id}") unless course.blank?
# 搜索到的资源 # 搜索到的资源
searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc') searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
#searched_attach = private_filter searched_attach #searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10) searched_attach = paginateHelper(searched_attach, 10)

@ -1,4 +1,6 @@
<h3><%=l(:label_attachment_new)%></h3> <h3>
<%=l(:label_attachment_new)%>
</h3>
<% attachmenttypes = course.attachmenttypes %> <% attachmenttypes = course.attachmenttypes %>
<%= error_messages_for 'attachment' %> <%= error_messages_for 'attachment' %>
<div id="network_issue" style="color: red; display: none;">上传出现错误,请您检查您的网络环境,并刷新页面重新上传。</div> <div id="network_issue" style="color: red; display: none;">上传出现错误,请您检查您的网络环境,并刷新页面重新上传。</div>
@ -8,8 +10,7 @@
<% if attachmenttypes.any? %> <% if attachmenttypes.any? %>
<%= l(:attachment_type) %></label> <%= l(:attachment_type) %></label>
<%= select_tag "attachment_type", <%= select_tag "attachment_type",
options_from_collection_for_select(attachmenttypes, "id", options_from_collection_for_select(attachmenttypes, "id","typeName", 2), {style: 'width:100px'} %>
"typeName", 2), {style: 'width:100px'} %>
<% end %> <% end %>
</p> </p>

Loading…
Cancel
Save