From 876c0e0e862a647d9105ed5b949fabbdaed227dd Mon Sep 17 00:00:00 2001 From: rkh Date: Thu, 29 Apr 2010 16:07:13 +0000 Subject: [PATCH] remove issue_patch.rb git-svn-id: https://dev.finn.de/svn/cockpit/trunk@971 7926756e-e54e-46e6-9721-ed318f58905e --- lib/issue_patch.rb | 74 ---------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 lib/issue_patch.rb diff --git a/lib/issue_patch.rb b/lib/issue_patch.rb deleted file mode 100644 index 2260e282ba..0000000000 --- a/lib/issue_patch.rb +++ /dev/null @@ -1,74 +0,0 @@ -require_dependency 'issue' - -# Patches Redmine's Issues dynamically. - -module IssuePatch - def self.included(base) # :nodoc: - base.extend(ClassMethods) - - base.send(:include, InstanceMethods) - - # Same as typing in the class - base.class_eval do - unloadable - - belongs_to :cost_object - has_many :cost_entries, :dependent => :delete_all - - # disabled for now, implements part of ticket blocking - #alias_method_chain :validate, :cost_object - end - end - - module ClassMethods - - end - - module InstanceMethods - def before_validation - self.overall_costs = self.labor_costs + self.material_costs - true - end - - def update_costs - overridden_costs = CostEntry.sum(:overridden_costs, :conditions => {:issue_id => id}) - normal_costs = CostEntry.sum(:costs, :conditions => {:overridden_costs => nil, :issue_id => id}) - self.material_costs = overridden_costs + normal_costs - - overridden_costs = TimeEntry.sum(:overridden_costs, :conditions => {:issue_id => id}) - normal_costs = TimeEntry.sum(:costs, :conditions => {:overridden_costs => nil, :issue_id => id}) - self.labor_costs = overridden_costs + normal_costs - - self.overall_costs = self.labor_costs + self.material_costs - end - - def update_costs! - self.update_costs - self.save! - end - - def validate_with_cost_object - if cost_object_id_changed? - if cost_object_id_was.nil? - # formerly unassigned ticket - errors.add :cost_object_id, :activerecord_error_invalid if cost_object.blocked? - else - old_cost_object = CostObject.find(cost_object_id_was) - errors.add :cost_object_id, :activerecord_error_invalid if old_cost_object.blocked? - end - end - - validate_without_cost_object - end - - # Wraps the association to get the Cost Object subject. Needed for the - # Query and filtering - def cost_object_subject - unless self.cost_object.nil? - return self.cost_object.subject - end - end - end -end - -