diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index ec3f0ab9a..e4ed35b4b 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -173,8 +173,8 @@ class HomeworkCommonsController < ApplicationController end # 排序 - rorder = params[:order] || "update_time" - b_order = params[:b_order] || "desc" + rorder = params[:order].blank? ? "update_time" : params[:order] + b_order = params[:b_order].blank? ? "desc" : params[:b_order] if rorder == "update_time" || rorder == "work_score" @student_works = @student_works.order("student_works.#{rorder} #{b_order}") elsif rorder == "student_id" diff --git a/app/models/user.rb b/app/models/user.rb index 0177d71a2..0d5517c50 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -390,13 +390,17 @@ class User < ApplicationRecord # 2、实训隐藏了只有管理员、实训合作者能看到 # 3、如果有限制学校范围,则学校的用户、管理员、实训合作者能看到 def shixun_permission(shixun) - case status + case shixun.status when -1 # 软删除只有管理员能访问 admin? when 0, 1, 3 # 申请发布或者已关闭的实训,只有实训管理员可以访问 manager_of_shixun?(shixun) when 2 - shixun.use_scope == 0 || manager_of_shixun?(shixun) || shixun.shixun_schools.exists?(school_id: school_id) + if shixun.hidden + manager_of_shixun?(shixun) + else + shixun.use_scope == 0 || manager_of_shixun?(shixun) || shixun.shixun_schools.exists?(school_id: school_id) + end end end diff --git a/app/views/shixuns/_shixun.json.jbuilder b/app/views/shixuns/_shixun.json.jbuilder index 6913c4745..ebc0c520d 100644 --- a/app/views/shixuns/_shixun.json.jbuilder +++ b/app/views/shixuns/_shixun.json.jbuilder @@ -13,7 +13,7 @@ json.array! shixuns do |shixun| json.identifier shixun.identifier json.name shixun.name json.status shixun.status - json.power (User.current.shixun_permission(shixun)) # 现在首页只显示已发布的实训 + json.power (current_user.shixun_permission(shixun)) # 现在首页只显示已发布的实训 # REDO: 局部缓存 json.tag_name shixun.tag_repertoires.first.try(:name) json.myshixuns_count shixun.myshixuns_count diff --git a/app/views/shixuns/_top.json.jbuilder b/app/views/shixuns/_top.json.jbuilder index ef15e2515..ebb77ec74 100644 --- a/app/views/shixuns/_top.json.jbuilder +++ b/app/views/shixuns/_top.json.jbuilder @@ -1,4 +1,4 @@ -json.status shixun.status +json.shixun_status shixun.status # REDO:前端需要通过status来判断发布 json.task_operation task_operation_url(current_myshixun, shixun)