|
|
@ -17,25 +17,27 @@ class FilesController < ApplicationController
|
|
|
|
sort_type = params[:sort_type] || 'created_on' # created_on:时间排序, downloads:下载次数排序; quotes: 引用次数排序
|
|
|
|
sort_type = params[:sort_type] || 'created_on' # created_on:时间排序, downloads:下载次数排序; quotes: 引用次数排序
|
|
|
|
course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id
|
|
|
|
course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id
|
|
|
|
@user = current_user || nil
|
|
|
|
@user = current_user || nil
|
|
|
|
@attachments = @course.attachments.by_keywords(params[:search])
|
|
|
|
@attachments = @course.attachments.by_course_second_category_id(course_second_category_id)
|
|
|
|
.includes(attachment_group_settings: :course_group, author: [:user_extension, :course_members])
|
|
|
|
.includes(attachment_group_settings: :course_group, author: [:user_extension, :course_members])
|
|
|
|
.by_course_second_category_id(course_second_category_id)
|
|
|
|
|
|
|
|
.ordered(sort: sort.to_i, sort_type: sort_type.strip)
|
|
|
|
.ordered(sort: sort.to_i, sort_type: sort_type.strip)
|
|
|
|
get_category(@course, course_second_category_id)
|
|
|
|
get_category(@course, course_second_category_id)
|
|
|
|
|
|
|
|
|
|
|
|
case @user.course_identity(@course)
|
|
|
|
@attachments =
|
|
|
|
when 5
|
|
|
|
case @user.course_identity(@course)
|
|
|
|
# 课程学生
|
|
|
|
when 5
|
|
|
|
@attachments = @attachments.published
|
|
|
|
@attachments.published
|
|
|
|
when 6 || 7
|
|
|
|
when 6, 7
|
|
|
|
# 非课堂成员
|
|
|
|
@attachments.publiced.published
|
|
|
|
@attachments = @attachments.publiced.published
|
|
|
|
else
|
|
|
|
end
|
|
|
|
@attachments
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@total_count = @attachments.size
|
|
|
|
@total_count = @attachments.size
|
|
|
|
@public_count = @attachments.publiced.size
|
|
|
|
@public_count = @attachments.publiced.size
|
|
|
|
@private_count = @total_count - @public_count
|
|
|
|
@private_count = @total_count - @public_count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attachments = @attachments.by_keywords(params[:search])
|
|
|
|
|
|
|
|
|
|
|
|
@attachments = @attachments.page(@page).per(@page_size)
|
|
|
|
@attachments = @attachments.page(@page).per(@page_size)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|