解决删除项目的私有资源显示在我的资源中的问题
This commit is contained in:
parent
378dfca006
commit
623114dc41
|
@ -836,8 +836,8 @@ class UsersController < ApplicationController
|
||||||
render_403
|
render_403
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.id}
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||||
|
@ -886,11 +886,11 @@ class UsersController < ApplicationController
|
||||||
def user_ref_resource_search
|
def user_ref_resource_search
|
||||||
search = params[:search].to_s.strip.downcase
|
search = params[:search].to_s.strip.downcase
|
||||||
if(params[:type].blank? || params[:type] == "1") #全部
|
if(params[:type].blank? || params[:type] == "1") #全部
|
||||||
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && 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','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 '%#{search}%') ").order("created_on desc")
|
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
|
||||||
elsif params[:type] == "2" #课程资源
|
elsif params[:type] == "2" #课程资源
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
|
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
|
||||||
elsif params[:type] == "3" #项目资源
|
elsif params[:type] == "3" #项目资源
|
||||||
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
|
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
|
||||||
|
@ -1579,16 +1579,14 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 上传用户资源
|
# 上传用户资源
|
||||||
def user_resource_create
|
def user_resource_create
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.id}
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
# 保存文件
|
# 保存文件
|
||||||
attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true)
|
attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true)
|
||||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
|
||||||
user_project_ids = User.current.projects.map {|p| p.id}
|
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||||
|
@ -2467,7 +2465,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 获取我的资源
|
# 获取我的资源
|
||||||
def get_my_resources author_id, user_course_ids, user_project_ids, order, score
|
def get_my_resources author_id, user_course_ids, user_project_ids, order, score
|
||||||
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
||||||
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
|
||||||
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||||
end
|
end
|
||||||
|
@ -2580,8 +2578,8 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.id}
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||||
|
@ -2638,8 +2636,8 @@ class UsersController < ApplicationController
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id}
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||||
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
|
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
|
||||||
|
@ -2677,8 +2675,8 @@ class UsersController < ApplicationController
|
||||||
# 别人的资源库是没有权限去看的
|
# 别人的资源库是没有权限去看的
|
||||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||||
user_course_ids = User.current.courses.map { |c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.id}
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
|
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
|
||||||
elsif params[:type] == "6" # 公共资源
|
elsif params[:type] == "6" # 公共资源
|
||||||
|
@ -2758,8 +2756,8 @@ class UsersController < ApplicationController
|
||||||
@user = User.current
|
@user = User.current
|
||||||
@switch_search = params[:search].nil? ? " " : params[:search]
|
@switch_search = params[:search].nil? ? " " : params[:search]
|
||||||
search = "%#{@switch_search.strip.downcase}%"
|
search = "%#{@switch_search.strip.downcase}%"
|
||||||
user_course_ids = User.current.courses.map {|c| c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.id}
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||||
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部
|
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部
|
||||||
if params[:status] == "2"
|
if params[:status] == "2"
|
||||||
@attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search)
|
@attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search)
|
||||||
|
|
|
@ -161,7 +161,7 @@
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="banner-txt">
|
<div class="banner-txt">
|
||||||
<h1><%= @organization.name %></h1>
|
<h1><%= @organization.name %></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue