删除附件的时候减掉得分

This commit is contained in:
huang 2016-01-14 16:04:59 +08:00
parent 01e8730b25
commit e9b54ad012
1 changed files with 7 additions and 7 deletions

View File

@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base
before_save :files_to_final_location,:act_as_course_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index
after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index#, :decrease_attchments_count
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count
# add by nwb
# 获取所有可公开的资源文件列表
@ -641,12 +641,12 @@ class Attachment < ActiveRecord::Base
end
end
# def decrease_attchments_count
# if self.container_type == "Project"
# count = self.container.attachments_count
# #self.container.update_attribute(:attachments_count, self.container.attachments_count - 1)
# end
# end
def decrease_attchments_count
if self.container_type == "Project" && !self.project.project_score.nil?
aatach_count = self.container.project_score.attach_num - 1+
self.container.project_score.update_attribute(:attach_num, aatach_count)
end
end
end
# Delete the previous articles index in Elasticsearch