pay_subject
cxt 5 years ago
parent 906c1d744f
commit 218611ee7f

@ -386,7 +386,7 @@ class CoursesController < ApplicationController
def destroy
if @course.is_delete == 0
@course.delete!
Tiding.where(belong_container: @course).update_all(delete: 1)
Tiding.where(belong_container: @course).update_all(is_delete: 1)
Tiding.create!(user_id: current_user.id, trigger_user_id: current_user.id, container_id: @course.id,
container_type: 'DeleteCourse', tiding_type: 'System', belong_container: @course, extra: @course.name)
normal_status(0, "成功")

@ -7,7 +7,7 @@ class Tiding < ApplicationRecord
has_many :attachments, as: :container
scope :visible, -> { where(delete: 0) }
scope :visible, -> { where(is_delete: 0) }
def identifier
value = nil

@ -1,5 +0,0 @@
class AddDeleteToTiding < ActiveRecord::Migration[5.2]
def change
add_column :tidings, :delete, :boolean, default: 0
end
end

@ -0,0 +1,5 @@
class AddIsDeleteToTiding < ActiveRecord::Migration[5.2]
def change
add_column :tidings, :is_delete, :boolean, default: 0
end
end

@ -1,5 +1,5 @@
class UpdateTidingDeleteStatus < ActiveRecord::Migration[5.2]
class UpdateTidingsDeleteStatus < ActiveRecord::Migration[5.2]
def change
Tiding.where.not(container_type: 'DeleteCourse').where(belong_container_type: "Course", belong_container_id: Course.where(is_delete: 1).pluck(:id)).update_all(delete: 1)
Tiding.where.not(container_type: 'DeleteCourse').where(belong_container_type: "Course", belong_container_id: Course.where(is_delete: 1).pluck(:id)).update_all(is_delete: 1)
end
end
Loading…
Cancel
Save