diff --git a/app/controllers/course_groups_controller.rb b/app/controllers/course_groups_controller.rb index 42a070734..fd59dd497 100644 --- a/app/controllers/course_groups_controller.rb +++ b/app/controllers/course_groups_controller.rb @@ -55,6 +55,12 @@ class CourseGroupsController < ApplicationController end end + # 邀请码停用/启用 + def set_invite_code_halt + @group.update!(invite_code_halt: !@group.invite_code_halt) + normal_status(0, "成功") + end + private def set_group diff --git a/config/routes.rb b/config/routes.rb index 9e89bc9a3..2ac176310 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -662,6 +662,7 @@ Rails.application.routes.draw do member do post 'rename_group' post 'move_category' + post 'set_invite_code_halt' end collection do diff --git a/db/migrate/20200219082337_add_code_halt_to_course_group.rb b/db/migrate/20200219082337_add_code_halt_to_course_group.rb new file mode 100644 index 000000000..1837e8be9 --- /dev/null +++ b/db/migrate/20200219082337_add_code_halt_to_course_group.rb @@ -0,0 +1,5 @@ +class AddCodeHaltToCourseGroup < ActiveRecord::Migration[5.2] + def change + add_column :course_groups, :invite_code_halt, :boolean, default: false + end +end