##// END OF EJS Templates
Added per user custom queries....
Added per user custom queries. Any logged in user can now save queries (they are not visible to the other users). Only users with explicit permission can manage queries that are visible to anyone. The queries list is removed from the "Reports" view. It can now be accessed from the issues list. git-svn-id: http://redmine.rubyforge.org/svn/trunk@566 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r476:52547466f0f1
r563:1c44600c62dc
Show More
time_entry.rb
33 lines | 1.3 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 class TimeEntry < ActiveRecord::Base
# could have used polymorphic association
# project association here allows easy loading of time entries at project level with one database trip
belongs_to :project
belongs_to :issue
belongs_to :user
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
validates_numericality_of :hours, :allow_nil => true
Jean-Philippe Lang
Fixed: 10342 Creation of Schema in Oracle...
r476 validates_length_of :comments, :maximum => 255
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365
def before_validation
self.project = issue.project if issue && project.nil?
end
def validate
Jean-Philippe Lang
added 999 as a maximum for time entry hours...
r366 errors.add :hours, :activerecord_error_invalid if hours && (hours < 0 || hours >= 1000)
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 errors.add :project_id, :activerecord_error_invalid if project.nil?
errors.add :issue_id, :activerecord_error_invalid if (issue_id && !issue) || (issue && project!=issue.project)
end
# tyear, tmonth, tweek assigned where setting spent_on attributes
# these attributes make time aggregations easier
def spent_on=(date)
super
self.tyear = spent_on ? spent_on.year : nil
self.tmonth = spent_on ? spent_on.month : nil
Jean-Philippe Lang
Fixed: 10342 Creation of Schema in Oracle...
r476 self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 end
end