From a84af9d13865bc556e878648f9b9a7551e15209b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 17:44:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=A7=81=E6=9C=89=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=9C=A8=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=9F=A5=E7=9C=8B=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 10 ++++++++++ app/helpers/files_helper.rb | 10 ---------- app/views/layouts/base_courses.html.erb | 7 +++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 408783934..f4ba5040e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -736,4 +736,14 @@ module CoursesHelper "未启用匿评".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 diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 884ebc2eb..749e7e437 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -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| diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index e787cfa54..25b08ce7d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -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)) %> @@ -94,7 +95,7 @@ <%= l(:label_account_identity_student)%>(<%= course_student_link student_num %>) - <%= l(:project_module_attachments)%>(<%= link_to @course.attachments.count, course_files_path(@course), :class => 'info_foot_num c_blue' %>) + <%= l(:project_module_attachments)%>(<%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue' %>)
@@ -125,7 +126,9 @@ <%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>