From 66c02f06679a02b83abec9aec0f88cd7dfee20a3 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 2 Jun 2015 11:58:21 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0HomeworkCommon=E7=9A=84Type=202=E3=80=81?= =?UTF-8?q?=E8=80=81=E5=B8=88=E5=88=9B=E5=BB=BA=E4=BD=9C=E4=B8=9A=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=80=81=E5=B8=88=E4=B8=AA=E4=BA=BA=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/owner_type_helper.rb | 1 + app/models/homework_common.rb | 13 ++++++++++++- .../homework_common/_homework_common_form.html.erb | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index dd5dbbbac..c03f2d19e 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -6,4 +6,5 @@ module OwnerTypeHelper COMMENT = 5 BID = 6 JOURNALSFORMESSAGE = 7 + HOMEWORKCOMMON = 8 end \ No newline at end of file diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index cb5c64778..b56406f19 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -11,6 +11,17 @@ class HomeworkCommon < ActiveRecord::Base has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 - + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 acts_as_attachable + + after_create :act_as_activity + after_destroy :delete_kindeditor_assets + + def act_as_activity + self.acts << Activity.new(:user_id => self.user_id) + end + #删除对应的图片 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON + end end diff --git a/app/views/homework_common/_homework_common_form.html.erb b/app/views/homework_common/_homework_common_form.html.erb index 2418c5650..cbe054335 100644 --- a/app/views/homework_common/_homework_common_form.html.erb +++ b/app/views/homework_common/_homework_common_form.html.erb @@ -12,7 +12,7 @@ <% if edit_mode %> - <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::BID %> + <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> <% else %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor' %>