Merge branches 'dev_aliyun' and 'dev_chen' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_chen

PCqiandao
杨树明 5 years ago
commit 65119c169d

@ -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

@ -7,6 +7,7 @@ json.data do
json.unpublish_count @unpublish_count
json.unlink_count @unlink_count
json.course_is_public @course.is_public?
json.parent_category_id @parent_category_id
json.files do
json.array! @attachments do |attachment|
json.is_history_file attachment.attachment_histories.count > 0 #是否有历史文件
@ -16,7 +17,7 @@ json.data do
end
# json.partial! "files/course_groups", attachment_group_settings: attachment.attachment_group_settings
json.category_id attachment.course_second_category_id
if @course_second_category_id.to_i == 0
unless @parent_category_id.present? && @parent_category_id != 0
json.category_name attachment.course_second_category&.name
end
end

Loading…
Cancel
Save