班级的课程id变为空时打印日志

This commit is contained in:
cxt 2016-08-11 15:58:49 +08:00
parent f4445619d2
commit 322868f063
4 changed files with 9 additions and 9 deletions

View File

@ -61,8 +61,7 @@ class AdminController < ApplicationController
if params[:syllabus_id] && params[:course_id]
course = Course.where("id = #{params[:course_id].to_i}").first
unless course.nil?
course.update_column('syllabus_id', params[:syllabus_id].to_i)
Rails.logger.error "update_syllabus_id: admin_controller/select_scourse_syllabus"
course.update_attribute(:syllabus_id, params[:syllabus_id].to_i)
@flag = true
end
end
@ -83,8 +82,7 @@ class AdminController < ApplicationController
syllabus.update_attributes(:title => params[:title], :eng_name => params[:eng_name], :user_id => @user.id)
syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content
if syllabus.save
course.update_column('syllabus_id', syllabus.id)
Rails.logger.error "update_syllabus_id: admin_controller/create_syllabus"
course.update_attribute(:syllabus_id, params[:syllabus_id].to_i)
@flag = params[:flag].to_i
@course = course
respond_to do |format|

View File

@ -80,6 +80,7 @@ class Course < ActiveRecord::Base
after_update :update_files_public,:update_course_ealasticsearch_index
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index
before_destroy :delete_all_members,:delete_course_ealasticsearch_index
after_save :log_infor
safe_attributes 'extra',
'time',
@ -504,6 +505,12 @@ class Course < ActiveRecord::Base
ticket
end
def log_infor
if self.syllabus_id.nil?
Rails.logger.info "##########################################################course's syllabus_id is null."
end
end
end

View File

@ -353,7 +353,6 @@ class CoursesService
#@course.password = params[:course][:password]
@course.tea_id = current_user.id
@course.syllabus_id = params[:syllabus_id].to_i
Rails.logger.error "update_syllabus_id: courses_service/create_course"
@course.term = params[:term]
@course.time = params[:time]
@course.end_term = params[:end_term]
@ -413,7 +412,6 @@ class CoursesService
#course.safe_attributes = params[:course]
#course.password = params[:course][:password]
course.syllabus_id = params[:syllabus_id].to_i
Rails.logger.error "update_syllabus_id: courses_service/edit_course"
course.time = params[:time]
course.term = params[:term]
course.end_time = params[:end_time]

View File

@ -86,14 +86,12 @@ class SyllabusesService
courses.each do |course|
if ::Course === course
course.syllabus_id = sy.id
Rails.logger.error "update_syllabus_id: syllabus_service/create"
course.save!
send_wechat_create_class_notice user,course
elsif Hash === course
c = ::Course.new(course)
c.tea_id = user.id
c.syllabus_id = sy.id
Rails.logger.error "update_syllabus_id: syllabus_service/create"
c.update_default_value
c.is_public = 0
c.save!
@ -138,7 +136,6 @@ class SyllabusesService
course.name = c
course.tea_id = user.id
course.syllabus_id = sy.id
Rails.logger.error "update_syllabus_id: syllabus_service/edit"
course.update_default_value
course.is_public = 0
course.save!