diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 9b12262af..70bce9566 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -444,9 +444,35 @@ class FilesController < ApplicationController # 获取提示中私有、公开总数信息 def get_attachment_for_tip all_attachment - @tip_all_attachments = all_attachment.count + @tip_all_public_attachments = all_attachment.select{|attach| attach.is_public == 1}.count - @tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count + if params[:project_id] + if User.current.member_of?(@project) || User.current.admin? + @tip_all_attachments = all_attachment.count + @tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count + else + if params[:tag_name] + @tip_all_attachments = all_attachment.count + @tip_all_private_attachments = 0 + else + @tip_all_attachments = Attachment.where(:container_id => params[:project_id], :container_type => "Project").count + @tip_all_private_attachments = Attachment.where(:container_id => params[:project_id], :container_type => "Project", :is_public => 0).count + end + end + elsif params[:course_id] + if User.current.member_of_course?(@course) || User.current.admin? + @tip_all_attachments = all_attachment.count + @tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count + else + if params[:tag_name] + @tip_all_attachments = all_attachment.count + @tip_all_private_attachments = 0 + else + @tip_all_attachments = Attachment.where(:container_id => params[:course_id], :container_type => "Course").count + @tip_all_private_attachments = Attachment.where(:container_id => params[:course_id], :container_type => "Course", :is_public => 0).count + end + end + end end def quote_resource_show diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c0e0919e..ffd30efc3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -820,6 +820,11 @@ module ApplicationHelper return @result end + def show_attachment_tip container_id, container_type + atts = Attachment.where(:container_id => container_id, :container_type => container_type, :is_public => 0) + atts.count > 0 ? true :false + end + # 必须是项目成,项目必须提交过代码 def allow_pull_request project return false if project.gpid.nil? diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 7449ec8e2..ebda40e6e 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -102,12 +102,14 @@
-
- - -

私有资源:
仅对本项目成员可见

-

公共资源:
对所有用户可见

-
+ <% if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %> +
+ + +

私有资源:
仅对本项目成员可见

+

公共资源:
对所有用户可见

+
+ <% end %>
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %> diff --git a/app/views/files/_tip_attachment_count.html.erb b/app/views/files/_tip_attachment_count.html.erb index 35ef949a9..b50e7bcaa 100644 --- a/app/views/files/_tip_attachment_count.html.erb +++ b/app/views/files/_tip_attachment_count.html.erb @@ -1,3 +1,15 @@ 共有 <%= @tip_all_attachments %> 个资源 公共资源:<%= @tip_all_public_attachments %>个 -私有资源:<%= @tip_all_private_attachments %>个 \ No newline at end of file +<% if @project %> + <% if !User.current.member_of?(@project) && params[:tag_name] %> + 私有资源:0个 + <% else %> + 私有资源:<%= @tip_all_private_attachments %>个 + <% end %> +<% elsif @course %> + <% if !User.current.member_of_course?(@course) && params[:tag_name] %> + 私有资源:0个 + <% else %> + 私有资源:<%= @tip_all_private_attachments %>个 + <% end %> +<% end %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 86a0a5518..027ef73e0 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,5 +1,6 @@ <%# course_model %> -<% course_file_num = visable_attachemnts_incourse(@course).count%> +<%# course_file_num = visable_attachemnts_incourse(@course).count%> +<% course_file_num = Attachment.where(:container_type => "Course", :container_id => @course.id).count %> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> <% homework_num = visable_course_homework @course %> diff --git a/public/stylesheets/css/public.css b/public/stylesheets/css/public.css index b19901016..663c9a69a 100644 --- a/public/stylesheets/css/public.css +++ b/public/stylesheets/css/public.css @@ -100,7 +100,7 @@ a.sendButtonBlue:hover {color:#ffffff;} a.resourcesTypeAll {background:url(../images/homepage_icon.png) -180px -89px no-repeat; padding-left:23px;} a.resourcesTypeAtt {background:url(../images/homepage_icon.png) -180px -49px no-repeat; padding-left:23px;} a.resourcesTypeUser {background:url(../images/homepage_icon.png) -178px -453px no-repeat; padding-left:23px;} -.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;} +.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;z-index: 999;} /*.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}*/ /*.resourcesUploadBox:hover {background-color:#0781b4;}*/