diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb index 72154b0a8..fb2246a50 100644 --- a/app/helpers/subjects_helper.rb +++ b/app/helpers/subjects_helper.rb @@ -1,12 +1,23 @@ module SubjectsHelper # 实训路径的发布状态 - def publish_status subject, is_manager, user + def publish_status subject, is_manager status = -1 if is_manager status = 0 if subject.status == 0 status = 1 if subject.status == 1 - status = 2 if subject.status == 2 && user.admin? + status = 2 if subject.status == 2 + end + status + end + + # 实训路径的公开状态 + def public_status subject, is_manager, user + status = -1 + if is_manager + status = 0 if subject.public == 0 + status = 1 if subject.public == 1 + status = 2 if subject.public == 2 && user.admin? end status end diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 49ad55517..d25437f0a 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -6,7 +6,8 @@ json.subject_score @subject.all_score json.member_count @subject.member_count json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin? -json.publish_status publish_status(@subject, @is_manager, @user) +json.publish_status publish_status(@subject, @is_manager) +json.public_status public_status(@subject, @is_manager, @user) json.allow_statistics @is_manager json.allow_send @user.logged? json.allow_visit @subject.status > 1 || @is_manager