diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ecd26870a..0131aa8be 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1953,7 +1953,7 @@ class UsersController < ApplicationController if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 - @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like :p) ",:p=>search).order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 4809bc643..c8fe0811e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -356,8 +356,9 @@ class Attachment < ActiveRecord::Base end #有了历史记录的数据记录是不能被删除的。 + #true 能被删除 false 不能被删除 def destroyable - Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty? && self.attachment_histories.count == 0 + self.attachment_histories.count == 0 end # Returns file's location on disk