##// END OF EJS Templates
Added request and controller objects to the hooks by default....
Added request and controller objects to the hooks by default. The request and controller objects are now added to all hook contexts by default. This will also make url_for work better in hooks by setting up the default_url_options :host, :port, and :protocol. Finally a new helper method @render_or@ has been added to ViewListener. This will let a hook easily render a partial without a full method definition. Thanks to Thomas Löber for the original patch. #2542 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2429 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r2249:6768bec4560e
r2368:5b7a5c39a7da
Show More
time_entry.rb
79 lines | 3.1 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Added time report....
r569 # redMine - project management software
Jean-Philippe Lang
Accept the following formats for the timelog "hours" field: 1h, 1 h, 1 hour, 2 hours, 30m, 30min, 1h30, 1h30m, 1:30....
r1305 # Copyright (C) 2006-2008 Jean-Philippe Lang
Jean-Philippe Lang
Added time report....
r569 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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
Jean-Philippe Lang
Adds atom feed on time entries details (#1479)....
r1546
Jean-Philippe Lang
Adds custom fields on time entries (#772)....
r1672 acts_as_customizable
Jean-Philippe Lang
Adds atom feed on time entries details (#1479)....
r1546 acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
:url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
:author => :user,
:description => :comments
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
Jean-Philippe Lang
Fixed: no error is raised when entering invalid hours on the issue update form (#2465)....
r2249 validates_numericality_of :hours, :allow_nil => true, :message => :activerecord_error_invalid
Jean-Philippe Lang
Fixed: Comment too long message when updating issue (#1550)....
r1594 validates_length_of :comments, :maximum => 255, :allow_nil => true
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365
Jean-Philippe Lang
Fixed: IssueController#edit doesn't set default Activity as default (#1302)....
r1447 def after_initialize
Jean-Philippe Lang
Fixed: time entries created with the default activity even if a different one is specified (#1302)....
r1519 if new_record? && self.activity.nil?
if default_activity = Enumeration.default('ACTI')
self.activity_id = default_activity.id
end
Jean-Philippe Lang
Fixed: IssueController#edit doesn't set default Activity as default (#1302)....
r1447 end
end
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
Jean-Philippe Lang
Accept the following formats for the timelog "hours" field: 1h, 1 h, 1 hour, 2 hours, 30m, 30min, 1h30, 1h30m, 1:30....
r1305 def hours=(h)
Jean-Philippe Lang
Fixed: no error is raised when entering invalid hours on the issue update form (#2465)....
r2249 write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
Jean-Philippe Lang
Accept the following formats for the timelog "hours" field: 1h, 1 h, 1 hour, 2 hours, 30m, 30min, 1h30, 1h30m, 1:30....
r1305 end
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 # 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
Adds date range filter and pagination on time entries detail view (closes #434)....
r1159 end
# Returns true if the time entry can be edited by usr, otherwise false
def editable_by?(usr)
Jean-Philippe Lang
Adds 2 permissions (closes #859):...
r1235 (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)
Jean-Philippe Lang
Adds date range filter and pagination on time entries detail view (closes #434)....
r1159 end
Jean-Philippe Lang
Propagates time tracking to the parent project (closes #433). Time report enhancements....
r1162
def self.visible_by(usr)
with_scope(:find => { :conditions => Project.allowed_to_condition(usr, :view_time_entries) }) do
yield
end
end
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 end