From 0fb454cca58cdbce989441cc7bef237d0623036a Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 3 Jul 2019 16:18:45 +0800 Subject: [PATCH] ADD files bulk publish --- app/controllers/files_controller.rb | 8 +++++++- config/routes.rb | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 2af178e47..05a9ab841 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -3,7 +3,7 @@ class FilesController < ApplicationController before_action :require_login, except: %i[index] before_action :find_course, except: %i[public_with_course_and_project mine_with_course_and_project] - before_action :find_ids, only: %i[bulk_delete bulk_send bulk_move bulk_public] + before_action :find_ids, only: %i[bulk_delete bulk_send bulk_move bulk_public bulk_publish] before_action :file_validate_sort_type, only: :index before_action :validate_send_message_to_course_params, only: :bulk_send before_action :set_pagination, only: %i[index public_with_course_and_project mine_with_course_and_project] @@ -40,6 +40,12 @@ class FilesController < ApplicationController @attachments = @attachments.page(@page).per(@page_size) end + def bulk_publish + return normal_status(403, "您没有权限进行操作") if current_user.course_identity(@course) >= 5 + @course.attachments.by_ids(@attachment_ids).unpublish.update_all(is_publish: 1, publish_time: Time.now) + render_ok + end + def bulk_delete ActiveRecord::Base.transaction do begin diff --git a/config/routes.rb b/config/routes.rb index a27dde1f3..f47b704b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -253,6 +253,7 @@ Rails.application.routes.draw do get :mine_with_course_and_project post :import post :upload + put :bulk_publish end member do get :histories