diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index e3c524fa..428e1157 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -893,6 +893,8 @@ class AttachmentsController < ApplicationController @subject = @attachment.container elsif @attachment.container_type == 'School' @school = @attachment.container + elsif @attachment.container_type == 'Library' + @library = @attachment.container else unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore' || @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'|| @attachment.container_type == 'Contest' || @attachment.container_type == 'HomeworkBank' || @attachment.container_type == 'Exercise' || @attachment.container_type == 'ExerciseBank' || @attachment.container_type == 'Career' || @attachment.container_type == 'EcTemplate' @project = @attachment.project diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index 8d1eeb06..c124c191 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -22,7 +22,7 @@ class LibrariesController < ApplicationController def show @library = Library.find(params[:id]) - return redirect_to libraries_path unless admin_or_self? + return render_403 unless admin_or_self? || @library.published? @library_applies = @library.library_applies.where(status: :refused).order('created_at desc') @library.increment_visited_count! diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 74ecd8c4..031c4399 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4368,6 +4368,8 @@ module ApplicationHelper elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses course = attachment.container.courses.first candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1) + elsif attachment.container_type == "Library" #文库允许下载 + candown = true else candown = (attachment.is_public == 1 || attachment.is_public == true) end