Mercurial > hg > soundsoftware-site
comparison app/models/time_entry.rb @ 929:5f33065ddc4b redmine-1.3
Update to Redmine SVN rev 9414 on 1.3-stable branch
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 14:54:18 +0100 |
parents | cbb26bc654de |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
909:cbb26bc654de | 929:5f33065ddc4b |
---|---|
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 class TimeEntry < ActiveRecord::Base | 18 class TimeEntry < ActiveRecord::Base |
19 include Redmine::SafeAttributes | |
19 # could have used polymorphic association | 20 # could have used polymorphic association |
20 # project association here allows easy loading of time entries at project level with one database trip | 21 # project association here allows easy loading of time entries at project level with one database trip |
21 belongs_to :project | 22 belongs_to :project |
22 belongs_to :issue | 23 belongs_to :issue |
23 belongs_to :user | 24 belongs_to :user |
43 | 44 |
44 named_scope :visible, lambda {|*args| { | 45 named_scope :visible, lambda {|*args| { |
45 :include => :project, | 46 :include => :project, |
46 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args) | 47 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args) |
47 }} | 48 }} |
49 | |
50 safe_attributes 'hours', 'comments', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values' | |
48 | 51 |
49 def after_initialize | 52 def after_initialize |
50 if new_record? && self.activity.nil? | 53 if new_record? && self.activity.nil? |
51 if default_activity = TimeEntryActivity.default | 54 if default_activity = TimeEntryActivity.default |
52 self.activity_id = default_activity.id | 55 self.activity_id = default_activity.id |