班级的资源,请显示课程下所有班级的资源
This commit is contained in:
parent
1193c4b145
commit
fb810a1993
|
@ -385,7 +385,7 @@ class FilesController < ApplicationController
|
|||
sort = "#{Attachment.table_name}.created_on desc"
|
||||
end
|
||||
|
||||
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
||||
@containers = @course.syllabus.courses.includes(:attachments).reorder(sort)
|
||||
|
||||
show_attachments @containers
|
||||
get_attachment_for_tip(@all_attachments)
|
||||
|
|
|
@ -51,6 +51,36 @@ module ApplicationHelper
|
|||
(User.current.id == applied_message.user_id && applied_message.status == 0) ? true : false
|
||||
end
|
||||
|
||||
# 课程某个班级的成员
|
||||
def syllabus_course_member user, course
|
||||
result = false
|
||||
syllabus = course.syllabus
|
||||
if syllabus
|
||||
syllabus.courses.each do |course|
|
||||
if user.member_of_course?(course)
|
||||
result = true
|
||||
return result
|
||||
end
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
# 课程某个班级的教师
|
||||
def syllabus_course_teacher user, course
|
||||
result = false
|
||||
syllabus = course.syllabus
|
||||
if syllabus
|
||||
syllabus.courses.each do |course|
|
||||
if user.allowed_to?(:as_teacher,course)
|
||||
result = true
|
||||
return result
|
||||
end
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
# 获取竞赛的管理人员
|
||||
def contest_managers contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")}
|
||||
|
|
|
@ -812,8 +812,9 @@ module CoursesHelper
|
|||
def visable_attachemnts_incourse course
|
||||
return[] unless course
|
||||
result = []
|
||||
course.attachments.each do |attachment|
|
||||
if attachment.is_public? && attachment.is_publish == 1 || User.current == attachment.author || User.current.allowed_to?(:as_teacher,course) || (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
|
||||
attachments = Attachment.where(:container_type => 'Course', :container_id => course.syllabus.courses.map(&:id))
|
||||
attachments.each do |attachment|
|
||||
if attachment.is_public? && attachment.is_publish == 1 || User.current == attachment.author || syllabus_course_teacher(User.current, Course.find(attachment.container_id)) || (syllabus_course_member(User.current, Course.find(attachment.container_id)) && attachment.is_publish == 1) || User.current.admin?
|
||||
result << attachment
|
||||
end
|
||||
end
|
||||
|
|
|
@ -118,14 +118,30 @@ module FilesHelper
|
|||
result
|
||||
end
|
||||
|
||||
# def visable_attachemnts attachments
|
||||
# result = []
|
||||
# attachments.each do |attachment|
|
||||
# if (attachment.is_public? && attachment.container_type != "Course") ||
|
||||
# (attachment.is_public? && attachment.container_type == "Course" && attachment.is_publish == 1)||
|
||||
# (attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
|
||||
# (attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))||
|
||||
# (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)||
|
||||
# attachment.author_id == User.current.id ||
|
||||
# (attachment.container_type == "OrgSubfield" and User.current.member_of_org?(attachment.container.organization))
|
||||
# result << attachment
|
||||
# end
|
||||
# end
|
||||
# result
|
||||
# end
|
||||
|
||||
def visable_attachemnts attachments
|
||||
result = []
|
||||
attachments.each do |attachment|
|
||||
if (attachment.is_public? && attachment.container_type != "Course") ||
|
||||
(attachment.is_public? && attachment.container_type == "Course" && attachment.is_publish == 1)||
|
||||
(attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
|
||||
(attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))||
|
||||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)||
|
||||
(attachment.container_type == "Course" && syllabus_course_teacher(User.current, Course.find(attachment.container_id)))||
|
||||
(attachment.container_type == "Course" && syllabus_course_member(User.current, Course.find(attachment.container_id)) && attachment.is_publish == 1)||
|
||||
attachment.author_id == User.current.id ||
|
||||
(attachment.container_type == "OrgSubfield" and User.current.member_of_org?(attachment.container.organization))
|
||||
result << attachment
|
||||
|
|
Loading…
Reference in New Issue