mirror of
https://github.com/redmine/redmine.git
synced 2024-08-27 17:54:48 +02:00
remove trailing white-spaces from time entry model source.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5820 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
32cb715db9
commit
6f8e3c031f
@ -5,12 +5,12 @@
|
||||
# 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.
|
||||
@ -22,7 +22,7 @@ class TimeEntry < ActiveRecord::Base
|
||||
belongs_to :issue
|
||||
belongs_to :user
|
||||
belongs_to :activity, :class_name => 'TimeEntryActivity', :foreign_key => 'activity_id'
|
||||
|
||||
|
||||
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||||
|
||||
acts_as_customizable
|
||||
@ -33,13 +33,13 @@ class TimeEntry < ActiveRecord::Base
|
||||
|
||||
acts_as_activity_provider :timestamp => "#{table_name}.created_on",
|
||||
:author_key => :user_id,
|
||||
:find_options => {:include => :project}
|
||||
:find_options => {:include => :project}
|
||||
|
||||
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||||
validates_numericality_of :hours, :allow_nil => true, :message => :invalid
|
||||
validates_length_of :comments, :maximum => 255, :allow_nil => true
|
||||
|
||||
named_scope :visible, lambda {|*args| {
|
||||
|
||||
named_scope :visible, lambda {|*args| {
|
||||
:include => :project,
|
||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)
|
||||
}}
|
||||
@ -52,21 +52,21 @@ class TimeEntry < ActiveRecord::Base
|
||||
self.hours = nil if hours == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def before_validation
|
||||
self.project = issue.project if issue && project.nil?
|
||||
end
|
||||
|
||||
|
||||
def validate
|
||||
errors.add :hours, :invalid if hours && (hours < 0 || hours >= 1000)
|
||||
errors.add :project_id, :invalid if project.nil?
|
||||
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project)
|
||||
end
|
||||
|
||||
|
||||
def hours=(h)
|
||||
write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
|
||||
end
|
||||
|
||||
|
||||
# tyear, tmonth, tweek assigned where setting spent_on attributes
|
||||
# these attributes make time aggregations easier
|
||||
def spent_on=(date)
|
||||
@ -78,12 +78,12 @@ class TimeEntry < ActiveRecord::Base
|
||||
self.tmonth = spent_on ? spent_on.month : nil
|
||||
self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil
|
||||
end
|
||||
|
||||
|
||||
# Returns true if the time entry can be edited by usr, otherwise false
|
||||
def editable_by?(usr)
|
||||
(usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)
|
||||
end
|
||||
|
||||
|
||||
# TODO: remove this method in 1.3.0
|
||||
def self.visible_by(usr)
|
||||
ActiveSupport::Deprecation.warn "TimeEntry.visible_by is deprecated and will be removed in Redmine 1.3.0. Use the visible scope instead."
|
||||
|
Loading…
Reference in New Issue
Block a user