|
|
|
@ -18,11 +18,23 @@ class FilesController < ApplicationController
|
|
|
|
|
sort_type = params[:sort_type] || 'created_on' # created_on:时间排序, downloads:下载次数排序; quotes: 引用次数排序
|
|
|
|
|
@course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id
|
|
|
|
|
@user = current_user
|
|
|
|
|
@attachments = @course_second_category_id.to_i == 0 ? @course.attachments.includes(:course_second_category) : @course.attachments.by_course_second_category_id(@course_second_category_id)
|
|
|
|
|
get_category(@course, @course_second_category_id)
|
|
|
|
|
|
|
|
|
|
# 主目录显示所有资源,一级目录显示一级和所属二级目录的资源,二级目录只显示该目录下的资源
|
|
|
|
|
if @course_second_category_id.to_i == 0
|
|
|
|
|
@attachments = @course.attachments.includes(:course_second_category)
|
|
|
|
|
else
|
|
|
|
|
if @parent_category_id == 0
|
|
|
|
|
category_ids = [@category_id] + @category.children.pluck(:id)
|
|
|
|
|
@attachments = @course.attachments.where(course_second_category_id: category_ids)
|
|
|
|
|
else
|
|
|
|
|
@attachments = @course.attachments.by_course_second_category_id(@course_second_category_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@attachments = @attachments.includes(author: [:user_extension, :course_members])
|
|
|
|
|
.ordered(sort: sort.to_i, sort_type: sort_type.strip)
|
|
|
|
|
|
|
|
|
|
get_category(@course, @course_second_category_id)
|
|
|
|
|
@total_count = @attachments.size
|
|
|
|
|
@unlink_count = @attachments.no_link.size
|
|
|
|
|
|
|
|
|
@ -354,9 +366,10 @@ class FilesController < ApplicationController
|
|
|
|
|
@category_id = category.try(:id)
|
|
|
|
|
@category_name = category.try(:module_name)
|
|
|
|
|
else
|
|
|
|
|
category = CourseSecondCategory.find category_id
|
|
|
|
|
@category = CourseSecondCategory.find category_id
|
|
|
|
|
@category_id = category.try(:id)
|
|
|
|
|
@category_name = category.try(:name)
|
|
|
|
|
@parent_category_id = category&.parent_id.to_i
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|