diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 5e0ef4638..fe707ac5b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -32,6 +32,13 @@ class CoursesController < ApplicationController before_filter :require_login, :only => [:join, :unjoin] #before_filter :allow_join, :only => [:join] + # 邀请码停用/启用 + def set_invite_code_halt + if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? + @course.update_attribute('invite_code_halt', @course.invite_code_halt == 0 ? 1 : 0) + end + end + #查找组织 def search_public_orgs_not_in_course condition = '%%' diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 43bdf9e09..c1c5f4f9f 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -584,6 +584,8 @@ class CoursesService @state = 2 elsif course[:is_delete] == 1 @state = 11 + elsif course[:invite_code_halt] == 1 + @state = 14 else if current_user.member_of_course?(course) #如果已经是成员 @state = 3 diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index a159886fd..ff094c1ff 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -10,7 +10,6 @@
请至少选择一个身份
+