From ffc36c5cf2c8e64fd204e04c54189a5d6cc55b60 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 23 Jul 2019 09:16:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A6=96=E9=A1=B5=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=A7=E5=88=B6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 4 ++-- app/helpers/subjects_helper.rb | 4 ++-- app/views/subjects/show.json.jbuilder | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index b372eb2c0..064061058 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -82,8 +82,8 @@ class SubjectsController < ApplicationController @is_creator = current_user.creator_of_subject?(@subject) # 合作团队 @members = @subject.subject_members.includes(:user) - shixun_ids = @subject.shixuns.published.pluck(:id) - challenge_ids = Challenge.where(shixun_id: shixun_ids).pluck(:id) + @shixuns = @subject.shixuns.published.pluck(:id) + challenge_ids = Challenge.where(shixun_id: @shixuns).pluck(:id) # 实训路径中的所有实训标签 @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq # 用户获取的实训标签 diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb index f0ecd1174..c464c7a7e 100644 --- a/app/helpers/subjects_helper.rb +++ b/app/helpers/subjects_helper.rb @@ -1,10 +1,10 @@ module SubjectsHelper # 实训路径的发布状态 - def publish_status subject, is_manager, user + def publish_status subject, is_manager, user, shixuns status = -1 if is_manager - status = 0 if subject.status == 0 && subject.shixuns_count > 0 + status = 0 if subject.status == 0 && shixuns.count > 0 status = 1 if subject.status == 1 status = 2 if subject.status == 2 && user.admin? end diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 14eb1942f..cafb08942 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -6,7 +6,7 @@ json.subject_score @subject.all_score json.member_count @subject.member_count json.allow_delete @is_creator && (@subject.status != 2 || @user.admin?) -json.publish_status publish_status(@subject, @is_creator, @user) +json.publish_status publish_status(@subject, @is_creator, @user, @shixuns) json.allow_statistics @user.manager_of_subject?(@subject) json.allow_send @user.logged? json.allow_visit @user.manager_of_subject?(@subject) || @user.admin? || @subject.status > 1