OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/lib/user_patch.rb

32 lines
745 B

# TODO: which require statement to use here? require_dependency breaks stuff
#require 'user'
# Patches Redmine's Users dynamically.
module UserPatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
# Same as typing in the class
base.class_eval do
unloadable
has_many :rates, :class_name => 'HourlyRate'
end
end
module ClassMethods
end
module InstanceMethods
def current_rate(project_id)
rate_at(Date.today, project_id)
end
def rate_at(date, project_id)
HourlyRate.find(:first, :conditions => [ "user_id = ? and project_id = ? and valid_from <= ?", id, project_id, date], :order => "valid_from DESC")
end
end
end