Moved and renamed files

pull/6827/head
Sebastian Schuster 11 years ago
parent eb2df99574
commit 8db4acd579
  1. 11
      app/models/costs_work_package_observer.rb
  2. 34
      lib/open_project/costs/patches/i18n_patch.rb
  3. 24
      lib/open_project/costs/patches/number_helper_patch.rb
  4. 21
      lib/open_project/costs/patches/work_package_observer.rb

@ -0,0 +1,11 @@
class CostsWorkPackageObserver < ActiveRecord::Observer
unloadable
observe :work_package
def after_update(work_package)
if work_package.project_id_changed?
# TODO: This only works with the global cost_rates
CostEntry.update_all({:project_id => work_package.project_id}, {:work_package_id => work_package.id})
end
end
end

@ -1,34 +0,0 @@
module OpenProject
module Costs
module Patches
module NumberHelper
def self.included(base) # :nodoc:
base.class_eval do
include InstanceMethods
alias_method_chain :number_to_currency, :l10n
end
end
module InstanceMethods
def number_to_currency_with_l10n(number, options = {})
options_with_default = { unit: ERB::Util.h(Setting.plugin_openproject_costs['costs_currency']),
format: ERB::Util.h(Setting.plugin_openproject_costs['costs_currency_format']),
delimiter: l(:currency_delimiter),
separator: l(:currency_separator) }.merge(options)
# FIXME: patch ruby instead of this code
# this circumvents the broken BigDecimal#to_f on Siemens's ruby
number = number.to_s if number.is_a? BigDecimal
number_to_currency_without_l10n(number, options_with_default)
end
end
end
end
end
end
unless ActionView::Helpers::NumberHelper.included_modules.include?(OpenProject::Costs::Patches::NumberHelper)
ActionView::Helpers::NumberHelper.send(:include, OpenProject::Costs::Patches::NumberHelper)
end

@ -0,0 +1,24 @@
module OpenProject::Costs::Patches::NumberHelperPatch
def self.included(base) # :nodoc:
base.class_eval do
include InstanceMethods
alias_method_chain :number_to_currency, :l10n
end
end
module InstanceMethods
def number_to_currency_with_l10n(number, options = {})
options_with_default = { unit: ERB::Util.h(Setting.plugin_openproject_costs['costs_currency']),
format: ERB::Util.h(Setting.plugin_openproject_costs['costs_currency_format']),
delimiter: l(:currency_delimiter),
separator: l(:currency_separator) }.merge(options)
# FIXME: patch ruby instead of this code
# this circumvents the broken BigDecimal#to_f on Siemens's ruby
number = number.to_s if number.is_a? BigDecimal
number_to_currency_without_l10n(number, options_with_default)
end
end
end

@ -1,21 +0,0 @@
require_dependency 'work_package'
class CostsWorkPackageObserver < ActiveRecord::Observer
unloadable
observe :work_package
def after_update(work_package)
if work_package.project_id_changed?
# TODO: This only works with the global cost_rates
CostEntry.update_all({:project_id => work_package.project_id}, {:work_package_id => work_package.id})
end
end
def before_update(work_package)
# FIXME: remove this method once controller_work_packages_move_before_save is in 0.9-stable
if work_package.project_id_changed? && work_package.cost_object_id && !work_package.project.cost_object_ids.include?(work_package.cost_object_id)
work_package.cost_object = nil
end
# true
end
end
Loading…
Cancel
Save