diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 89fddb36..289c122b 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -496,7 +496,7 @@ class StudentWorkController < ApplicationController def _index # REDO:分班信息提前查出来,然后循环中根据匹配去取 - @is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) : false + @is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin? || User.current.business?) : false @member = @course.members.where(:user_id => User.current.id).first # 判断学生是否有权限查看(作业未发布、作业已发布但不是统一设置的未分班学生、分班设置的作业未发布) if User.current.member_of_course?(@course) && !@is_teacher diff --git a/app/models/user.rb b/app/models/user.rb index 52c4be8b..db1ff58a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1119,7 +1119,7 @@ class User < Principal end def member_of_course?(course) - courses.to_a.include?(course) + courses.to_a.include?(course) || User.current.business? end def member_of_contest?(contest) @@ -1323,7 +1323,7 @@ class User < Principal if Project === context return false unless context.allows_to?(action) # Admin users are authorized for anything else - return true if admin? + return true if admin? || business? # 课程:作品关联项目的老师也可以访问私有项目 course_ids = context.student_work_projects.blank? ? "(-1)" : "(" + context.student_work_projects.map{|swp| swp.course_id}.join(",") + ")" diff --git a/app/views/users/_l_course.html.erb b/app/views/users/_l_course.html.erb index 1a16703f..b7dcf029 100644 --- a/app/views/users/_l_course.html.erb +++ b/app/views/users/_l_course.html.erb @@ -46,7 +46,7 @@ <%#= render :partial => "users/course_item", :locals => {:objects => @objects} %> <% @objects.each do |object| %> - <% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) %> + <% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) || User.current.business? %>