Merge branch 'szzh' into develop
This commit is contained in:
commit
520597b065
|
@ -87,8 +87,9 @@ class AttachmentsController < ApplicationController
|
|||
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
|
||||
elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses
|
||||
candown = User.current.member_of_course?(@attachment.container.courses.first) || (course.is_public == 1 && @attachment.is_public == 1)
|
||||
elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses.first
|
||||
course = @attachment.container.courses.first
|
||||
candown = User.current.member_of_course?(course) || (course.is_public == 1 && @attachment.is_public == 1)
|
||||
else
|
||||
|
||||
candown = @attachment.is_public == 1
|
||||
|
@ -203,7 +204,11 @@ class AttachmentsController < ApplicationController
|
|||
if @attachment.container.respond_to?(:init_journal)
|
||||
@attachment.container.init_journal(User.current)
|
||||
end
|
||||
if @attachment.container
|
||||
@attachment.container.attachments.delete(@attachment)
|
||||
else
|
||||
@attachment.destroy
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if !@attachment.container.nil? &&
|
||||
|
|
|
@ -71,9 +71,9 @@ class FilesController < ApplicationController
|
|||
@searched_attach = paginateHelper @result,10
|
||||
end
|
||||
|
||||
rescue Exception => e
|
||||
#render 'stores'
|
||||
redirect_to stores_url
|
||||
#rescue Exception => e
|
||||
# #render 'stores'
|
||||
# redirect_to search_course_files_url
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -107,13 +107,46 @@ module FilesHelper
|
|||
def visable_attachemnts_insite attachments,course
|
||||
result = []
|
||||
attachments.each do |attachment|
|
||||
if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == course.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
|
||||
if attachment_candown(attachment) || (attachment.container_type == "Course" && attachment.container_id == course.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
|
||||
result << attachment
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def attachment_candown attachment
|
||||
candown = false
|
||||
if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
|
||||
project = attachment.container.project
|
||||
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif attachment.container.is_a?(Project)
|
||||
project = attachment.container
|
||||
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
|
||||
attachment.container.board.project
|
||||
project = attachment.container.board.project
|
||||
candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course
|
||||
course = attachment.container.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) || (course.is_public==1 && attachment.is_public == 1)
|
||||
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
|
||||
attachment.container.board.course
|
||||
course = attachment.container.board.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
|
||||
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)
|
||||
else
|
||||
candown = (attachment.is_public == 1 || attachment.is_public == true)
|
||||
end
|
||||
candown
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
Loading…
Reference in New Issue