From e1fc3fff3e6493403de436ab92dd53daab87eeec Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 7 Nov 2019 17:57:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/models/user.rb | 5 +++++ .../graduation_topics/_graduation_comments.json.jbuilder | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 5dd001f5a..dd8c7c5c0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1141,7 +1141,7 @@ class CoursesController < ApplicationController # 如果在该课堂已经存在学生身份,且邀请码为分班邀请码,则将其直接加入分班 existing_student.update_attributes(course_group_id: course_group.id) if course_group.present? else - correspond_teacher_exist = current_user.teacher_of_course? course + correspond_teacher_exist = current_user.none_admin_teacher_of_course? course new_student = CourseMember.new(user_id: current_user.id, course_id: course.id, role: 4) new_student.is_active = 0 if correspond_teacher_exist diff --git a/app/models/user.rb b/app/models/user.rb index 5d9ccd0ba..abab82927 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -287,6 +287,11 @@ class User < ApplicationRecord course.course_members.exists?(user_id: id, role: [1,2,3], is_active: 1) || admin? || business? end + # 课堂的老师(创建者、老师、助教),不考虑超管和运营人员 + def none_admin_teacher_of_course?(course) + course.course_members.exists?(user_id: id, role: [1,2,3], is_active: 1) + end + # 课堂的老师(创建者、老师、助教),不用考虑当前身份 def teacher_of_course_non_active?(course) course.course_members.exists?(user_id: id, role: [1,2,3]) diff --git a/app/views/graduation_topics/_graduation_comments.json.jbuilder b/app/views/graduation_topics/_graduation_comments.json.jbuilder index e52395fbf..03002e82e 100644 --- a/app/views/graduation_topics/_graduation_comments.json.jbuilder +++ b/app/views/graduation_topics/_graduation_comments.json.jbuilder @@ -3,8 +3,8 @@ json.author do end json.id message.id -json.content content_safe(message.contents_show(identity)) -# json.content message.contents_show(identity) +# json.content content_safe(message.contents_show(identity)) +json.content message.contents_show(identity) json.time time_from_now(message.created_at) json.hidden message.hidden # 主贴与子贴不一致