From dc3672f2d7f8f790661b4a0cc6dec4bffb5bb590 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 15:58:30 +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 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7ebf7435d..c0c2cda3f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -796,18 +796,15 @@ class CoursesController < ApplicationController if approval == 1 course_message.pass! - new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id) content = course_message.content.to_i - if content == 3 || content == 7 - tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 3).any? - new_teacher.ASSISTANT_PROFESSOR! - elsif content == 2 || content == 9 - tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 2).any? - new_teacher.PROFESSOR! + role = (content == 3 || content == 7) ? 3 : ((content == 2 || content == 9) ? 2 : nil) + if role + tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: [1, 2 ,3]).any? else tip_exception("申请角色错误") end + new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id, role: role) new_teacher.save! # 课堂管理员才有分配权限,且课堂分班数大于0