From 89875130b48c6b885f8e8992da03806714e845b9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Mar 2020 12:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=A7=86=E8=A7=92=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=9C=AA=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 4 +++- app/models/attachment.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8f024c1c6..0ee83e839 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -238,7 +238,9 @@ module CoursesHelper # 获取课堂的资源数 def get_attachment_count(course, category_id) - category_id.to_i == 0 ? course.attachments.size : course.attachments.where(course_second_category_id: category_id).size + identity = current_user.course_identity(course) + attachments = category_id.to_i == 0 ? course.attachments : course.attachments.where(course_second_category_id: category_id) + identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size end # 获取课堂的视频数 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3ff9a6a90..1a9b50c3b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -24,6 +24,7 @@ class Attachment < ApplicationRecord scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) } scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} + scope :published, -> {where(is_publish: 1)} validates_length_of :description, maximum: 100, message: "不能超过100个字符"