diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c303c7e78..c8fd042ea 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -16,12 +16,17 @@ class FilesController < ApplicationController sort = params[:sort] || 0 # 0: 降序;1: 升序 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 || nil + @user = current_user @attachments = @course.attachments.by_course_second_category_id(course_second_category_id) .includes(attachment_group_settings: :course_group, 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 + @public_count = @attachments.publiced.size + @private_count = @total_count - @public_count + @attachments = @attachments.by_keywords(params[:search]) @attachments = case @user.course_identity(@course) when 5 @@ -32,12 +37,6 @@ class FilesController < ApplicationController @attachments end - @total_count = @attachments.size - @public_count = @attachments.publiced.size - @private_count = @total_count - @public_count - - @attachments = @attachments.by_keywords(params[:search]) - @attachments = @attachments.page(@page).per(@page_size) end