From 50011985a9d25ca27ef42b6fb6ea31e3bbf08d2f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Mar 2016 11:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B5=84=E6=BA=90=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 1 + app/controllers/users_controller.rb | 9 ++++++--- app/views/files/_resource_detail.html.erb | 4 ++++ app/views/files/_upload_course_files.erb | 8 ++++++++ app/views/files/index.html.erb | 1 - 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ca37e445c..e615de002 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -529,6 +529,7 @@ class FilesController < ApplicationController if attachment.publish_time > Date.today attachment.is_publish = 0 end + attachment.description = params[:description] attachment.save end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3114ef5e0..671a6b446 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2403,9 +2403,12 @@ class UsersController < ApplicationController search = "%#{params[:search].strip.downcase}%" 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','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") + 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} + @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')) "+ + "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)) 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的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 6342e91f6..bac00a68d 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -27,6 +27,10 @@

文件大小:<%= number_to_human_size(file.filesize) %>

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+ <% unless file.description.blank? %> +
+
资源描述:<%= file.description %>
+ <% end %>
diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index de43977cd..d728d7a2d 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -22,6 +22,14 @@ <%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
+
+ +
+ +
+
+
+ <% if User.current.allowed_to?(:as_teacher,course) %>
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index d4d12232e..27e51f05c 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -13,7 +13,6 @@
<% end %> -