删除课堂时将课堂相关消息置为删除状态

pay_subject
cxt 5 years ago
parent 4d2f30f39e
commit da368ae908

@ -386,6 +386,7 @@ class CoursesController < ApplicationController
def destroy
if @course.is_delete == 0
@course.delete!
Tiding.where(belong_container: @course).update_all(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, "成功")

@ -5,7 +5,7 @@ class TidingsController < ApplicationController
after_action :update_onclick_time!, only: [:index]
def index
tidings = current_user.tidings
tidings = current_user.tidings.visible
@onclick_time = current_user.click_time
tiding_types =
@ -21,7 +21,7 @@ class TidingsController < ApplicationController
tidings = tidings.where(container_type: 'JoinCourse', status: 0) if params[:type] == 'course_apply'
# @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse', status: 0).count
@course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse', status: 0).count
@course_apply_count = tidings.where(container_type: 'JoinCourse', status: 0).count
tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package'

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

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

@ -0,0 +1,5 @@
class UpdateTidingDeleteStatus < 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)
end
end
Loading…
Cancel
Save