|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
class Memo < ActiveRecord::Base
|
|
|
|
|
include Redmine::SafeAttributes
|
|
|
|
|
belongs_to :forums
|
|
|
|
|
belongs_to :forum
|
|
|
|
|
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
|
|
|
|
|
|
|
|
|
validates_presence_of :author_id, :forum_id, :subject
|
|
|
|
@ -13,10 +13,10 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
acts_as_attachable
|
|
|
|
|
belongs_to :last_reply_id, :class_name => 'Memo', :foreign_key => 'last_reply_id'
|
|
|
|
|
# acts_as_searchable :column => ['subject', 'content'],
|
|
|
|
|
# #:include => { :forums => :p}
|
|
|
|
|
# #:include => { :forum => :p}
|
|
|
|
|
# #:project_key => "#{Forum.table_name}.project_id"
|
|
|
|
|
# :date_column => "#{table_name}.created_at"
|
|
|
|
|
# acts_as_event :title => Proc.new {|o| "#{o.forums.name}: #{o.subject}"},
|
|
|
|
|
# acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
|
|
|
|
|
# :description => :content,
|
|
|
|
|
# :group => :parent,
|
|
|
|
|
# :type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
|
|
|
|
@ -29,7 +29,7 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
"subject",
|
|
|
|
|
"content",
|
|
|
|
|
"forum_id",
|
|
|
|
|
"last_reply_id",
|
|
|
|
|
"last_memo_id",
|
|
|
|
|
"lock",
|
|
|
|
|
"parent_id",
|
|
|
|
|
"replies_count",
|
|
|
|
@ -39,8 +39,8 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
# after_update :update_memos_forum
|
|
|
|
|
after_destroy :reset_counters!
|
|
|
|
|
# after_create :send_notification
|
|
|
|
|
after_save :plusParentAndForum
|
|
|
|
|
after_destroy :minusParentAndForum
|
|
|
|
|
# after_save :plusParentAndForum
|
|
|
|
|
# after_destroy :minusParentAndForum
|
|
|
|
|
|
|
|
|
|
# scope :visible, lambda { |*args|
|
|
|
|
|
# includes(:forum => ).where()
|
|
|
|
@ -62,7 +62,7 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
if parent && parent.id
|
|
|
|
|
Memo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
|
|
|
|
|
end
|
|
|
|
|
# forums.reset_counters!
|
|
|
|
|
forum.reset_counters!
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def sticky=(arg)
|
|
|
|
|