From 8f2499613456391cba2a63ae2deb1bc57fb55d42 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 17 Jul 2019 10:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 4 ++-- app/controllers/course_modules_controller.rb | 3 ++- app/controllers/course_second_categories_controller.rb | 2 +- app/controllers/courses_controller.rb | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 0bcaaa2c0..1081a82ce 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -2,10 +2,10 @@ class BoardsController < ApplicationController before_action :require_login, :check_auth before_action :find_course, only: [:create] before_action :set_board, except: [:create] - before_action :teacher_allowed + before_action :teacher_or_admin_allowed def index - @boards = @course.boards.includes(messages: [:last_reply, :author]); + @boards = @course.boards.includes(messages: [:last_reply, :author]) end def show diff --git a/app/controllers/course_modules_controller.rb b/app/controllers/course_modules_controller.rb index 4e9f7b908..6e8afd525 100644 --- a/app/controllers/course_modules_controller.rb +++ b/app/controllers/course_modules_controller.rb @@ -2,7 +2,7 @@ class CourseModulesController < ApplicationController before_action :require_login, :check_auth before_action :set_module, except: [:unhidden_modules] before_action :find_course, only: [:unhidden_modules] - before_action :teacher_allowed + before_action :teacher_or_admin_allowed # 模块置顶 def sticky_module @@ -16,6 +16,7 @@ class CourseModulesController < ApplicationController # 模块隐藏 def hidden_module + tip_exception("请至少保留一个课堂模块") if @course.none_hidden_course_modules.where.not(id: @course_module.id).size == 0 @course_module.update_attributes(hidden: 1) normal_status(0, "更新成功") end diff --git a/app/controllers/course_second_categories_controller.rb b/app/controllers/course_second_categories_controller.rb index ca544a584..af368a8dc 100644 --- a/app/controllers/course_second_categories_controller.rb +++ b/app/controllers/course_second_categories_controller.rb @@ -1,7 +1,7 @@ class CourseSecondCategoriesController < ApplicationController before_action :require_login, :check_auth before_action :set_category - before_action :teacher_allowed + before_action :teacher_or_admin_allowed # 目录重命名 def rename_category diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 94c8a4ec1..8ea5a7174 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1057,6 +1057,7 @@ class CoursesController < ApplicationController tip_exception("课堂名称应以课程名称开头命名") unless params[:course][:name].index(params[:course_list_name]) && params[:course][:name].index(params[:course_list_name]) == 0 tip_exception("课堂所属单位不能为空!") if params[:school].blank? + tip_exception("请至少添加一个课堂模块") if params[:course_module_types].blank? @school = School.find_by!(name: params[:school].strip) end