From bc0e24d39e421b37721ea4d38c75ea5d04bb3e13 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 24 May 2016 10:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BC=95=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 160 +++++++++--------- app/views/users/_resources_list.html.erb | 45 +---- .../users/_user_import_resource_list.html.erb | 16 +- app/views/users/_user_resource_info.html.erb | 10 +- .../users/_user_resource_tip_list.html.erb | 2 +- app/views/users/user_resource.html.erb | 6 +- 6 files changed, 96 insertions(+), 143 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2c4355180..853219426 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2058,18 +2058,18 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end - elsif params[:type] == "2" - apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} - if params[:status] == "2" - resource_type = "'Course'" - elsif params[:status] == "3" - resource_type = "'Project'" - elsif params[:status] == "5" - resource_type = "'Principal'" - else - resource_type = "'Project','OrgSubfield','Principal','Course'" - end - @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) + # elsif params[:type] == "2" + # apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} + # if params[:status] == "2" + # resource_type = "'Course'" + # elsif params[:status] == "3" + # resource_type = "'Project'" + # elsif params[:status] == "5" + # resource_type = "'Principal'" + # else + # resource_type = "'Project','OrgSubfield','Principal','Course'" + # end + # @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) end @type = params[:type] @limit = 25 @@ -2211,18 +2211,18 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end - elsif params[:type] == "2" - apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} - if params[:status] == "2" - resource_type = "'Course'" - elsif params[:status] == "3" - resource_type = "'Project'" - elsif params[:status] == "5" - resource_type = "'Principal'" - else - resource_type = "'Project','OrgSubfield','Principal','Course'" - end - @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) + # elsif params[:type] == "2" + # apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} + # if params[:status] == "2" + # resource_type = "'Course'" + # elsif params[:status] == "3" + # resource_type = "'Project'" + # elsif params[:status] == "5" + # resource_type = "'Principal'" + # else + # resource_type = "'Project','OrgSubfield','Principal','Course'" + # end + # @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) end @status = params[:status] @type = params[:type] @@ -2352,18 +2352,18 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end - elsif params[:type] == "2" - apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} - if params[:status] == "2" - resource_type = "'Course'" - elsif params[:status] == "3" - resource_type = "'Project'" - elsif params[:status] == "5" - resource_type = "'Principal'" - else - resource_type = "'Project','OrgSubfield','Principal','Course'" - end - @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) + # elsif params[:type] == "2" + # apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} + # if params[:status] == "2" + # resource_type = "'Course'" + # elsif params[:status] == "3" + # resource_type = "'Project'" + # elsif params[:status] == "5" + # resource_type = "'Principal'" + # else + # resource_type = "'Project','OrgSubfield','Principal','Course'" + # end + # @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) end @type = params[:type] @limit = 25 @@ -2700,12 +2700,12 @@ class UsersController < ApplicationController # 获取公共资源 def get_public_resources user_course_ids, user_project_ids, order, score - attachments = Attachment.where("(is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}") + attachments = Attachment.where("(is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取公共资源搜索 def get_public_resources_search user_course_ids, user_project_ids, order, score, search - attachments = Attachment.where("is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的资源 @@ -2729,15 +2729,15 @@ class UsersController < ApplicationController and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") end - # 获取我的私有资源分享结果 - def get_my_private_resources apply_ids, resource_type, order, score - attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type})").order("#{order.nil? ? 'created_on' : order} #{score}") - end - - # 获取我的私有资源分享搜索结果 - def get_my_private_resources_search apply_ids, resource_type, order, score, search - attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type}) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") - end + # # 获取我的私有资源分享结果 + # def get_my_private_resources apply_ids, resource_type, order, score + # attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type})").order("#{order.nil? ? 'created_on' : order} #{score}") + # end + # + # # 获取我的私有资源分享搜索结果 + # def get_my_private_resources_search apply_ids, resource_type, order, score, search + # attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type}) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + # end # 获取我的课程资源中搜索结果 def get_course_resources_search author_id, user_course_ids, order, score, search @@ -2748,12 +2748,12 @@ class UsersController < ApplicationController # 获取公共资源中课程资源 def get_course_resources_public user_course_ids, order, score - attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1)").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取公共资源中课程资源搜索结果 def get_course_resources_public_search user_course_ids, order, score, search - attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的项目资源 @@ -2772,12 +2772,12 @@ class UsersController < ApplicationController # 获取公共资源的项目资源 def get_project_resources_public user_project_ids, order, score - attchments = Attachment.where("container_type = 'Project' and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取公共资源的项目资源搜索 def get_project_resources_public_search user_project_ids, order, score, search - attchments = Attachment.where("(container_type = 'Project' and container_id is not null) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我上传的附件 @@ -2795,13 +2795,13 @@ class UsersController < ApplicationController # 获取公共资源中我上传的附件 def get_attch_resources_public order, score attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') - and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") + and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取公共资源中我上传的附件 def get_attch_resources_public_search order, score, search attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') - and container_id is not null) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 @@ -2816,12 +2816,12 @@ class UsersController < ApplicationController # 获取我的用户类型资源 def get_principal_resources_public order, score - attchments = Attachment.where("container_type = 'Principal' and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("container_type = 'Principal' and is_public =1 and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 def get_principal_resources_public_search order, score, search - attchments = Attachment.where("(container_type = 'Principal'and container_id is not null) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 资源库 分为全部 课程资源 项目资源 附件 @@ -2863,18 +2863,18 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end - elsif params[:type] == "2" # 私有资源 - apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} - if params[:status] == "2" - resource_type = "'Course'" - elsif params[:status] == "3" - resource_type = "'Project'" - elsif params[:status] == "5" - resource_type = "'Principal'" - else - resource_type = "'Project','OrgSubfield','Principal','Course'" - end - @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) + # elsif params[:type] == "2" # 私有资源 + # apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} + # if params[:status] == "2" + # resource_type = "'Course'" + # elsif params[:status] == "3" + # resource_type = "'Project'" + # elsif params[:status] == "5" + # resource_type = "'Principal'" + # else + # resource_type = "'Project','OrgSubfield','Principal','Course'" + # end + # @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) end @status = params[:status] @type = params[:type] @@ -3054,19 +3054,19 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search) end - elsif params[:type] == "2" # 私有资源 - apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} - if params[:status] == "2" - resource_type = "'Course'" - elsif params[:status] == "3" - resource_type = "'Project'" - elsif params[:status] == "5" - resource_type = "'Principal'" - else - resource_type = "'Project','OrgSubfield','Principal','Course'" - end - @attachments = get_my_private_resources_search(apply_ids, resource_type, @order, @score, search) - @attachments + # elsif params[:type] == "2" # 私有资源 + # apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} + # if params[:status] == "2" + # resource_type = "'Course'" + # elsif params[:status] == "3" + # resource_type = "'Project'" + # elsif params[:status] == "5" + # resource_type = "'Principal'" + # else + # resource_type = "'Project','OrgSubfield','Principal','Course'" + # end + # @attachments = get_my_private_resources_search(apply_ids, resource_type, @order, @score, search) + # @attachments end @status = params[:status] @type = params[:type] diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 3aaed7594..d22b69760 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -6,55 +6,20 @@ <% attachments.each do |attach| %>
@@ -219,7 +184,7 @@ } line.children().css("background-color", 'white'); id = line.children().last().html(); - user_id = line.children().eq(6).html(); + user_id = line.children().eq(5).html(); if(user_id === '<%= User.current.id%>') { if(line.children().first().children().data('hasHistory') == 'Y'){ alert('该资源存在历史版本,不能删除'); @@ -228,7 +193,7 @@ if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) { $.ajax({ type: 'post', - url: '<%= user_resource_delete_user_path(User.current.id)%>' + '?resource_id=' + id + '&type=<%=@type %>&status=<%=@status %>' + url: '<%= user_resource_delete_user_path(User.current.id) %>' + '?resource_id=' + id + '&type=<%= @type %>&status=<%= @status %>' }); } diff --git a/app/views/users/_user_import_resource_list.html.erb b/app/views/users/_user_import_resource_list.html.erb index e8ed684c6..97366832b 100644 --- a/app/views/users/_user_import_resource_list.html.erb +++ b/app/views/users/_user_import_resource_list.html.erb @@ -6,22 +6,10 @@