From 782bbc775b66a1d2bfb69417b63b91ffefdd44ec Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 4 Mar 2016 21:04:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 62 +++- app/views/users/_resources_list.html.erb | 347 ++++++++++++++++++++++ app/views/users/_upload_resource.html.erb | 4 +- app/views/users/user_resource.html.erb | 345 --------------------- 4 files changed, 402 insertions(+), 356 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 34d40f177..da351a402 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1538,9 +1538,20 @@ class UsersController < ApplicationController #@user.save_attachments(params[:attachments],User.current) # Container_type为Principal Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) - if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 + if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + if params[:status] == 2 + @attachments = get_course_resources(params[:id], user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources params[:id] + elsif params[:status] == "5" + @attachments = get_principal_resources params[:id] + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + end elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids) elsif params[:type] == "3" # 项目资源 @@ -1550,10 +1561,21 @@ class UsersController < ApplicationController elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources params[:id] elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources_public + elsif params[:status] == "5" + @attachments = get_principal_resources_public + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids) + end end - @type = params[:type] || 1 + @status = params[:status] + @type = params[:type] @limit = 25 @is_remote = true @atta_count = @attachments.count @@ -1578,9 +1600,20 @@ class UsersController < ApplicationController 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} - if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 + if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + if params[:status] == 2 + @attachments = get_course_resources(params[:id], user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources params[:id] + elsif params[:status] == "5" + @attachments = get_principal_resources params[:id] + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + end elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids) elsif params[:type] == "3" # 项目资源 @@ -1590,9 +1623,20 @@ class UsersController < ApplicationController elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources params[:id] elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources_public + elsif params[:status] == "5" + @attachments = get_principal_resources_public + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids) + end end + @status = params[:status] @type = params[:type] @limit = 25 @is_remote = true diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 4e429a640..7bd44ccf0 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -25,3 +25,350 @@
<% end %> <% end %> + + diff --git a/app/views/users/_upload_resource.html.erb b/app/views/users/_upload_resource.html.erb index c973217f6..ae9114dfa 100644 --- a/app/views/users/_upload_resource.html.erb +++ b/app/views/users/_upload_resource.html.erb @@ -2,7 +2,7 @@ 上传资源
- <%= form_tag(user_resource_create_user_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> + <%= form_tag(user_resource_create_user_path(:type=>type,:status=>status), :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
<% if defined?(container) && container && container.saved_attachments %> @@ -38,7 +38,7 @@
(未选择文件)
-
您可以上传小于50MB的文件
+
diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 6e01b90fb..f45eb11c2 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -21,16 +21,6 @@ $("#resource_search_form").submit(); } - function show_upload(){ - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'upload_resource' ,:locals => {:user=>@user})%>'); - showModal('ajax-modal', '452px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top","50%").css("left","50%").css("position","absolute"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); - } - function show_public_resource(){ $("#resource_remote").html('<%= escape_javascript( render :partial => 'user_resource_info' ,:locals => { :tpye => 6}) %>'); } @@ -115,340 +105,5 @@
- -