"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "app/models/time_entry.rb" between
redmine-4.1.0.tar.gz and redmine-4.1.1.tar.gz

About: Redmine is a flexible project management and bug-tracking web application (using the Ruby on Rails framework). It supports also project wikis and forums, documents management, and multiple version control systems.

time_entry.rb  (redmine-4.1.0):time_entry.rb  (redmine-4.1.1)
skipping to change at line 53 skipping to change at line 53
:author_key => :user_id, :author_key => :user_id,
:scope => joins(:project).preload(:project) :scope => joins(:project).preload(:project)
validates_presence_of :author_id, :user_id, :activity_id, :project_id, :hours, :spent_on validates_presence_of :author_id, :user_id, :activity_id, :project_id, :hours, :spent_on
validates_presence_of :issue_id, :if => lambda { Setting.timelog_required_fiel ds.include?('issue_id') } validates_presence_of :issue_id, :if => lambda { Setting.timelog_required_fiel ds.include?('issue_id') }
validates_presence_of :comments, :if => lambda { Setting.timelog_required_fiel ds.include?('comments') } validates_presence_of :comments, :if => lambda { Setting.timelog_required_fiel ds.include?('comments') }
validates_numericality_of :hours, :allow_nil => true, :message => :invalid validates_numericality_of :hours, :allow_nil => true, :message => :invalid
validates_length_of :comments, :maximum => 1024, :allow_nil => true validates_length_of :comments, :maximum => 1024, :allow_nil => true
validates :spent_on, :date => true validates :spent_on, :date => true
before_validation :set_project_if_nil before_validation :set_project_if_nil
#TODO: remove this, author should be always explicitly set
before_validation :set_author_if_nil before_validation :set_author_if_nil
validate :validate_time_entry validate :validate_time_entry
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
joins(:project). joins(:project).
where(TimeEntry.visible_condition(args.shift || User.current, *args)) where(TimeEntry.visible_condition(args.shift || User.current, *args))
} }
scope :left_join_issue, lambda { scope :left_join_issue, lambda {
joins("LEFT OUTER JOIN #{Issue.table_name} ON #{Issue.table_name}.id = #{Tim eEntry.table_name}.issue_id") joins("LEFT OUTER JOIN #{Issue.table_name} ON #{Issue.table_name}.id = #{Tim eEntry.table_name}.issue_id")
} }
skipping to change at line 119 skipping to change at line 120
if issue_id_changed? && issue if issue_id_changed? && issue
if issue.visible?(user) && user.allowed_to?(:log_time, issue.project) if issue.visible?(user) && user.allowed_to?(:log_time, issue.project)
if attrs[:project_id].blank? && issue.project_id != project_id if attrs[:project_id].blank? && issue.project_id != project_id
self.project_id = issue.project_id self.project_id = issue.project_id
end end
@invalid_issue_id = nil @invalid_issue_id = nil
else else
@invalid_issue_id = issue_id @invalid_issue_id = issue_id
end end
end end
if user_id_changed? && user_id != author_id && !user.allowed_to?(:log_time
_for_other_users, project)
@invalid_user_id = user_id
else
@invalid_user_id = nil
end
end end
attrs attrs
end end
def set_project_if_nil def set_project_if_nil
self.project = issue.project if issue && project.nil? self.project = issue.project if issue && project.nil?
end end
def set_author_if_nil def set_author_if_nil
self.author = User.current if author.nil? self.author = User.current if author.nil?
skipping to change at line 149 skipping to change at line 155
if logged_hours + hours > max_hours if logged_hours + hours > max_hours
errors.add( errors.add(
:base, :base,
I18n.t(:error_exceeds_maximum_hours_per_day, I18n.t(:error_exceeds_maximum_hours_per_day,
:logged_hours => format_hours(logged_hours), :logged_hours => format_hours(logged_hours),
:max_hours => format_hours(max_hours))) :max_hours => format_hours(max_hours)))
end end
end end
end end
errors.add :project_id, :invalid if project.nil? errors.add :project_id, :invalid if project.nil?
errors.add :user_id, :invalid if user_id != author_id && !self.assignable_us if @invalid_user_id || (user_id_changed? && user_id != author_id && !self.as
ers.map(&:id).include?(user_id) signable_users.map(&:id).include?(user_id))
errors.add :user_id, :invalid
end
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project! =issue.project) || @invalid_issue_id errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project! =issue.project) || @invalid_issue_id
errors.add :activity_id, :inclusion if activity_id_changed? && project && !p roject.activities.include?(activity) errors.add :activity_id, :inclusion if activity_id_changed? && project && !p roject.activities.include?(activity)
if spent_on_changed? && user if spent_on_changed? && user
errors.add :base, I18n.t(:error_spent_on_future_date) if !Setting.timelog_ accept_future_dates? && (spent_on > user.today) errors.add :base, I18n.t(:error_spent_on_future_date) if !Setting.timelog_ accept_future_dates? && (spent_on > user.today)
end end
end end
def hours=(h) def hours=(h)
write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h) write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
end end
 End of changes. 3 change blocks. 
2 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)