This repository has been archived on 2024-12-01. You can view files and clone it, but cannot push or open issues or pull requests.
redmine_rodax_crm/app/models/deal_note.rb
2012-01-03 16:18:32 +00:00

24 lines
1.2 KiB
Ruby

class DealNote < Note
unloadable
belongs_to :deal, :foreign_key => :source_id
acts_as_searchable :columns => ["#{table_name}.content"],
:include => [:deal => :project],
:project_key => "#{Project.table_name}.id",
:permission => :view_deals,
# sort by id so that limited eager loading doesn't break with postgresql
:order_column => "#{table_name}.id"
acts_as_activity_provider :type => 'contacts',
:permission => :view_deals,
:author_key => :author_id,
:find_options => {:include => [:deal => :project],
:conditions => {:source_type => 'Deal'}}
named_scope :visible, lambda {|*args| { :include => [:deal => :project],
:conditions => Project.allowed_to_condition(args.first || User.current, :view_deals) +
" AND (#{DealNote.table_name}.source_type = 'Deal')"} }
end