From 4e8eda64d70db312e8a82110bb57f6c97c47539c Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sat, 3 Oct 2020 15:36:59 +0000 Subject: [PATCH] shorten long line of TimelogController git-svn-id: http://svn.redmine.org/redmine/trunk@20116 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/timelog_controller.rb | 29 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 782ee5d14..b694137e8 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -79,7 +79,10 @@ class TimelogController < ApplicationController respond_to do |format| format.html { render :layout => !request.xhr? } - format.csv { send_data(report_to_csv(@report), :type => 'text/csv; header=present', :filename => 'timelog.csv') } + format.csv do + send_data(report_to_csv(@report), :type => 'text/csv; header=present', + :filename => 'timelog.csv') + end end end @@ -92,19 +95,25 @@ class TimelogController < ApplicationController end def new - @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :author => User.current, :spent_on => User.current.today) + @time_entry ||= + TimeEntry.new(:project => @project, :issue => @issue, + :author => User.current, :spent_on => User.current.today) @time_entry.safe_attributes = params[:time_entry] end def create - @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :author => User.current, :user => User.current, :spent_on => User.current.today) + @time_entry ||= + TimeEntry.new(:project => @project, :issue => @issue, + :author => User.current, :user => User.current, + :spent_on => User.current.today) @time_entry.safe_attributes = params[:time_entry] if @time_entry.project && !User.current.allowed_to?(:log_time, @time_entry.project) render_403 return end - call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) + call_hook(:controller_timelog_edit_before_save, + {:params => params, :time_entry => @time_entry}) if @time_entry.save respond_to do |format| @@ -131,7 +140,9 @@ class TimelogController < ApplicationController redirect_back_or_default project_time_entries_path(@time_entry.project) end } - format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) } + format.api do + render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) + end end else respond_to do |format| @@ -147,7 +158,8 @@ class TimelogController < ApplicationController def update @time_entry.safe_attributes = params[:time_entry] - call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) + call_hook(:controller_timelog_edit_before_save, + {:params => params, :time_entry => @time_entry}) if @time_entry.save respond_to do |format| @@ -189,7 +201,10 @@ class TimelogController < ApplicationController @time_entries.each do |time_entry| time_entry.reload time_entry.safe_attributes = attributes - call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry }) + call_hook( + :controller_time_entries_bulk_edit_before_save, + {:params => params, :time_entry => time_entry} + ) if time_entry.save saved_time_entries << time_entry else -- 2.39.5