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/lib/redmine_contacts/patches/project_patch.rb
2012-01-03 21:11:44 +00:00

25 lines
1.1 KiB
Ruby

module RedmineContacts
module Patches
module ProjectPatch
def self.included(base) # :nodoc:
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
has_and_belongs_to_many :contacts, :order => "last_name, first_name", :uniq => true
has_many :deals, :dependent => :delete_all
has_many :contracts, :dependent => :delete_all
has_many :deal_categories, :dependent => :delete_all, :order => "#{DealCategory.table_name}.name"
has_many :contract_categories, :dependent => :delete_all, :order => "#{ContractCategory.table_name}.name"
has_and_belongs_to_many :deal_statuses, :order => "#{DealStatus.table_name}.position", :uniq => true
has_and_belongs_to_many :contract_statuses, :order => "#{ContractStatus.table_name}.position", :uniq => true
end
end
end
end
end
Dispatcher.to_prepare do
unless Project.included_modules.include?(RedmineContacts::Patches::ProjectPatch)
Project.send(:include, RedmineContacts::Patches::ProjectPatch)
end
end