优化资源搜索界面

GitlabVersion
nwb 11 years ago
parent 02b4029e8c
commit f4d6696d2e

@ -55,32 +55,33 @@ class AttachmentsController < ApplicationController
candown = false
if @attachment.container.has_attribute?(:project) && @attachment.container.project
project = @attachment.container.project
candown= User.current.member_of?(project)
candown= User.current.member_of?(project) || (project.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Project)
project = @attachment.container
candown= User.current.member_of?(project)
candown= User.current.member_of?(project) || (project.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
course = @attachment.container.course
candown= User.current.member_of_course?(course)
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Course)
course = @attachment.container
candown= User.current.member_of_course?(course)
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
candown = true
end
if candown || User.current.admin?
@attachment.increment_download
if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment')
end
else
render_403 :message => :notice_not_authorized
end
if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment')
end
rescue => e
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end

@ -38,7 +38,7 @@ class StoresController < ApplicationController
LIMIT = 12 unless const_defined?(:LIMIT)
def index
@projects_attach = project_classification(0).take(LIMIT)
@courses_attach = Attachment.includes(:course).where("courses.is_public = ?", 1).
@courses_attach = Attachment.includes(:course).where("courses.is_public = 1").
where(container_type: 'Course').
limit(LIMIT)
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).

@ -16,6 +16,8 @@ module StoresHelper
news_path(container)
when 'Project'
project_files_path(container)
when 'Course'
course_files_path(container)
when 'Version'
# version_path(container)
project_files_path(container.project)

Loading…
Cancel
Save