From 929da7512da5d1c17d8e913b7e7937424faabead Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 19 Aug 2015 17:13:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 33 ++++++++- .../users/_resource_search_form.html.erb | 2 +- .../users/_resource_share_popup.html.erb | 15 +++- app/views/users/_resources_list.html.erb | 5 +- app/views/users/user_resource.html.erb | 58 +++++++++------- public/stylesheets/images/homepage_icon.png | Bin 0 -> 6829 bytes public/stylesheets/images/nav_icon.png | Bin 0 -> 3204 bytes public/stylesheets/public_new.css | 65 ++++++++++++++---- 8 files changed, 133 insertions(+), 45 deletions(-) create mode 100644 public/stylesheets/images/homepage_icon.png create mode 100644 public/stylesheets/images/nav_icon.png diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c523bbb3d..e4109e5bb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -825,7 +825,38 @@ class UsersController < ApplicationController # 删除用户资源 def user_resource_delete Attachment.delete(params[:resource_id]) - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + #@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + if(params[:type].nil? || params[:type] == "1") #全部 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + else + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "2" #课程资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") + else + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "3" #项目资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") + end + elsif params[:type] == "4" #附件 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + end + end + @type = params[:type] respond_to do |format| format.js end diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb index 725167b65..5f854cba0 100644 --- a/app/views/users/_resource_search_form.html.erb +++ b/app/views/users/_resource_search_form.html.erb @@ -2,6 +2,6 @@ :remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> <%= hidden_field_tag(:type,type) %> - <%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %> + <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %> <% end %> \ No newline at end of file diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index 01ac79075..cad94056c 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -1,8 +1,17 @@ -
将资源移动至 -
+
+
将资源发送至
+
+ +
+
+
+
<%= form_tag search_user_course_user_path(user),:method => 'get', :remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %> <%= hidden_field_tag(:send_id, @send_id) %> @@ -17,7 +26,7 @@ <%= hidden_field_tag(:send_id, @send_id) %> <% if !courses.empty? %> <% courses.each do |course| %> -
    +
    • diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 6f9ba0fee..b344c737d 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,7 +1,10 @@ <% if attachments.nil? || attachments.empty? %> <% else %> <% attachments.each do |attach| %> -
        +
          +
        • + +
        • <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 621b0c17d..5867c463f 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -40,22 +40,22 @@ }
          -
          -
          资源
          +
          +
          资源库
            • - <%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesTypeAll resourcesGrey' %>
            • - <%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'homepagePostTypeAssignment postTypeGrey' %>
            • - <%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'homepagePostTypeQuiz postTypeGrey' %>
            • - <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %>
          • @@ -63,14 +63,14 @@
          <%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %>
            +
          • 资源名称
          • 大小
          • 类别
          • @@ -78,11 +78,21 @@
          • 上传时间
          -
          -
            - +
            <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> -
          +
          +
          +
          + +
          + 全选 + 删除 +
          +
          选择 10 个资源
          +
          + 发送 +
          +