课程私有资源不显示在没有权限查看的用户上

This commit is contained in:
sw 2015-03-30 17:44:40 +08:00
parent 5954ced7a7
commit a84af9d138
3 changed files with 15 additions and 12 deletions

View File

@ -736,4 +736,14 @@ module CoursesHelper
"<span class='fr mr10 pr_join_span '>未启用匿评</span>".html_safe
end
end
def visable_attachemnts_incourse course
result = []
course.attachments.each do |attachment|
if attachment.is_public? || User.current.member_of_course?(course)
result << attachment
end
end
result
end
end

View File

@ -97,16 +97,6 @@ module FilesHelper
result
end
def visable_attachemnts_incourse attachments
result = []
attachments.each do |attachment|
if attachment.is_public? || (attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
result << attachment
end
end
result
end
def visable_attachemnts_insite attachments,course
result = []
attachments.each do |attachment|

View File

@ -1,6 +1,7 @@
<% course_model %>
<% teacher_num = teacherCount(@course) %>
<% student_num = studentCount(@course) %>
<% course_file_num = visable_attachemnts_incourse(@course).count%>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<!DOCTYPE html>
<html lang="en">
@ -94,7 +95,7 @@
<span>|&nbsp;</span>
<%= l(:label_account_identity_student)%><%= course_student_link student_num %>
<span>|&nbsp;</span>
<%= l(:project_module_attachments)%><%= link_to @course.attachments.count, course_files_path(@course), :class => 'info_foot_num c_blue' %></div>
<%= l(:project_module_attachments)%><%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue' %></div>
<div class="cl"></div>
</div><!--课程信息 end-->
<div class="info_box">
@ -125,7 +126,9 @@
<%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>
</div>
<div class="subNav">
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02" %><%= link_to "(#{@course.attachments.count})", course_files_path(@course), :class => "subnav_num c_orange" %><%= link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white') if is_teacher %>
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02" %>
<%= link_to "(#{course_file_num})", course_files_path(@course), :class => "subnav_num c_orange" %>
<%= link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white') if is_teacher %>
</div>
<div class="subNav">
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>