From 9a0a45967b5396ec5183b749f8ed1d34e0301390 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sat, 24 Oct 2020 14:39:47 +0000 Subject: [PATCH] shorten long line of app/models/time_entry.rb git-svn-id: http://svn.redmine.org/redmine/trunk@20181 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/time_entry.rb | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index b2d3f58e4..0dc343475 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -28,17 +28,21 @@ class TimeEntry < ActiveRecord::Base belongs_to :activity, :class_name => 'TimeEntryActivity' acts_as_customizable - acts_as_event :title => - Proc.new {|o| - related = o.issue if o.issue && o.issue.visible? - related ||= o.project - "#{l_hours(o.hours)} (#{related.event_title})" - }, - :url => Proc.new {|o| {:controller => 'timelog', :action => 'index', :project_id => o.project, :issue_id => o.issue}}, - :author => :user, - :group => :issue, - :description => :comments - + acts_as_event( + :title => + Proc.new do |o| + related = o.issue if o.issue && o.issue.visible? + related ||= o.project + "#{l_hours(o.hours)} (#{related.event_title})" + end, + :url => + Proc.new do |o| + {:controller => 'timelog', :action => 'index', :project_id => o.project, :issue_id => o.issue} + end, + :author => :user, + :group => :issue, + :description => :comments + ) acts_as_activity_provider :timestamp => "#{table_name}.created_on", :author_key => :user_id, :scope => proc { joins(:project).preload(:project) } @@ -66,7 +70,9 @@ class TimeEntry < ActiveRecord::Base where("#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}") } - safe_attributes 'user_id', 'hours', 'comments', 'project_id', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values', 'custom_fields' + safe_attributes 'user_id', 'hours', 'comments', 'project_id', + 'issue_id', 'activity_id', 'spent_on', + 'custom_field_values', 'custom_fields' # Returns a SQL conditions string used to find all time entries visible by the specified user def self.visible_condition(user, options={}) -- 2.39.5