课堂消息

dev_newshixunModel
cxt 5 years ago
parent a9cfd823c2
commit 77b610851a

@ -307,8 +307,8 @@ class CoursesController < ApplicationController
def destroy def destroy
if @course.is_delete == 0 if @course.is_delete == 0
@course.delete! @course.delete!
Tiding.create!(user_id: @course.tea_id, trigger_user_id: 0, container_id: @course.id, Tiding.create!(user_id: current_user.id, trigger_user_id: current_user.id, container_id: @course.id,
container_type: 'Course', tiding_type: 'Delete', extra: @course.name) container_type: 'DeleteCourse', tiding_type: 'System', belong_container: @course, extra: @course.name)
normal_status(0, "成功") normal_status(0, "成功")
else else
normal_status(-1, "课堂已删除,无需重复操作") normal_status(-1, "课堂已删除,无需重复操作")
@ -572,6 +572,10 @@ class CoursesController < ApplicationController
tip_exception("删除失败") if course_member.CREATOR? or course_member.STUDENT? tip_exception("删除失败") if course_member.CREATOR? or course_member.STUDENT?
course_student = CourseMember.find_by(user_id: course_member.user_id, course_id: @course.id, role: %i[STUDENT]) course_student = CourseMember.find_by(user_id: course_member.user_id, course_id: @course.id, role: %i[STUDENT])
# Tiding.create!(user_id: course_member.user_id, trigger_user_id: current_user.id, container_id: @course.id,
# container_type: 'DeleteCourseMember', tiding_type: 'System', belong_container: @course, extra: @course.name)
CourseDeleteStudentNotifyJob.perform_later(@course.id, [course_member.user_id], current_user.id)
course_member.destroy! course_member.destroy!
course_student.update_attributes(is_active: 1) if course_student.present? && !course_student.is_active course_student.update_attributes(is_active: 1) if course_student.present? && !course_student.is_active
normal_status(0, "删除成功") normal_status(0, "删除成功")
@ -802,6 +806,7 @@ class CoursesController < ApplicationController
end end
end end
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, student_ids) if student_ids.present? CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, student_ids) if student_ids.present?
CourseDeleteStudentNotifyJob.perform_later(@course.id, student_ids, current_user.id) if student_ids.present?
normal_status(0, "操作成功") normal_status(0, "操作成功")
rescue => e rescue => e
uid_logger(e.message) uid_logger(e.message)

@ -134,6 +134,15 @@ module TidingDecorator
end end
end end
def delete_course_content
I18n.t(locale_format) % container.name
end
def delete_course_member_content
name = Course.find_by(id: container_id)&.name
I18n.t(locale_format) % [trigger_user&.show_real_name, name]
end
def shixun_content def shixun_content
I18n.t(locale_format) % container.name I18n.t(locale_format) % container.name
end end

@ -0,0 +1,22 @@
# 删除课堂用户
class CourseDeleteStudentNotifyJob < ApplicationJob
queue_as :notify
def perform(course_id, student_ids, trigger_user_id)
course = Course.find_by(id: course_id)
return if course.blank?
attrs = %i[user_id trigger_user_id container_id container_type belong_container_id
belong_container_type tiding_type created_at updated_at]
same_attrs = {
trigger_user_id: trigger_user_id, container_id: course.id, container_type: 'DeleteCourseMember',
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'System'
}
Tiding.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end

@ -58,8 +58,8 @@
"2_end": "你提交的试用授权申请,审核未通过<br/><span>原因:%{reason}</span>" "2_end": "你提交的试用授权申请,审核未通过<br/><span>原因:%{reason}</span>"
Apply_end: "提交了试用授权申请" Apply_end: "提交了试用授权申请"
Course_end: "你创建了课堂:%s" Course_end: "你创建了课堂:%s"
Course: DeleteCourse_end: "你删除了课堂:%s"
Delete_end: "你删除了课堂%s" DeleteCourseMember_end: "%s 将从课堂中删除了:%s"
Shixun_end: "你创建了实训:%s" Shixun_end: "你创建了实训:%s"
Subject_end: "你创建了实践课程:%s" Subject_end: "你创建了实践课程:%s"
ArchiveCourse_end: "你的课堂已经归档:%s" ArchiveCourse_end: "你的课堂已经归档:%s"

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CourseDeleteStudentNotifyJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save