##// END OF EJS Templates
remove trailing white-spaces from app/controllers/timelog_controller.rb....
Toshi MARUYAMA -
r6398:dd43df81804f
parent child
Show More
@@ -5,12 +5,12
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -24,14 +24,14 class TimelogController < ApplicationController
24 24 before_filter :find_optional_project, :only => [:index]
25 25 accept_rss_auth :index
26 26 accept_api_auth :index, :show, :create, :update, :destroy
27
27
28 28 helper :sort
29 29 include SortHelper
30 30 helper :issues
31 31 include TimelogHelper
32 32 helper :custom_fields
33 33 include CustomFieldsHelper
34
34
35 35 def index
36 36 sort_init 'spent_on', 'desc'
37 37 sort_update 'spent_on' => 'spent_on',
@@ -40,14 +40,14 class TimelogController < ApplicationController
40 40 'project' => "#{Project.table_name}.name",
41 41 'issue' => 'issue_id',
42 42 'hours' => 'hours'
43
43
44 44 cond = ARCondition.new
45 45 if @issue
46 46 cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
47 47 elsif @project
48 48 cond << @project.project_condition(Setting.display_subprojects_issues?)
49 49 end
50
50
51 51 retrieve_date_range
52 52 cond << ['spent_on BETWEEN ? AND ?', @from, @to]
53 53
@@ -56,7 +56,7 class TimelogController < ApplicationController
56 56 # Paginate results
57 57 @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
58 58 @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
59 @entries = TimeEntry.visible.find(:all,
59 @entries = TimeEntry.visible.find(:all,
60 60 :include => [:project, :activity, :user, {:issue => :tracker}],
61 61 :conditions => cond.conditions,
62 62 :order => sort_clause,
@@ -69,7 +69,7 class TimelogController < ApplicationController
69 69 format.api {
70 70 @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
71 71 @offset, @limit = api_offset_and_limit
72 @entries = TimeEntry.visible.find(:all,
72 @entries = TimeEntry.visible.find(:all,
73 73 :include => [:project, :activity, :user, {:issue => :tracker}],
74 74 :conditions => cond.conditions,
75 75 :order => sort_clause,
@@ -86,7 +86,7 class TimelogController < ApplicationController
86 86 }
87 87 format.csv {
88 88 # Export all entries
89 @entries = TimeEntry.visible.find(:all,
89 @entries = TimeEntry.visible.find(:all,
90 90 :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
91 91 :conditions => cond.conditions,
92 92 :order => sort_clause)
@@ -94,7 +94,7 class TimelogController < ApplicationController
94 94 }
95 95 end
96 96 end
97
97
98 98 def show
99 99 respond_to do |format|
100 100 # TODO: Implement html response
@@ -106,7 +106,7 class TimelogController < ApplicationController
106 106 def new
107 107 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
108 108 @time_entry.attributes = params[:time_entry]
109
109
110 110 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
111 111 render :action => 'edit'
112 112 end
@@ -115,9 +115,9 class TimelogController < ApplicationController
115 115 def create
116 116 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
117 117 @time_entry.attributes = params[:time_entry]
118
118
119 119 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
120
120
121 121 if @time_entry.save
122 122 respond_to do |format|
123 123 format.html {
@@ -131,21 +131,21 class TimelogController < ApplicationController
131 131 format.html { render :action => 'edit' }
132 132 format.api { render_validation_errors(@time_entry) }
133 133 end
134 end
134 end
135 135 end
136
136
137 137 def edit
138 138 @time_entry.attributes = params[:time_entry]
139
139
140 140 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
141 141 end
142 142
143 143 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
144 144 def update
145 145 @time_entry.attributes = params[:time_entry]
146
146
147 147 call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
148
148
149 149 if @time_entry.save
150 150 respond_to do |format|
151 151 format.html {
@@ -159,7 +159,7 class TimelogController < ApplicationController
159 159 format.html { render :action => 'edit' }
160 160 format.api { render_validation_errors(@time_entry) }
161 161 end
162 end
162 end
163 163 end
164 164
165 165 def bulk_edit
@@ -186,7 +186,7 class TimelogController < ApplicationController
186 186
187 187 verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
188 188 def destroy
189 @time_entries.each do |t|
189 @time_entries.each do |t|
190 190 begin
191 191 unless t.destroy && t.destroyed?
192 192 respond_to do |format|
@@ -258,7 +258,7 private
258 258 rescue ActiveRecord::RecordNotFound
259 259 render_404
260 260 end
261
261
262 262 def find_optional_project
263 263 if !params[:issue_id].blank?
264 264 @issue = Issue.find(params[:issue_id])
@@ -268,7 +268,7 private
268 268 end
269 269 deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true)
270 270 end
271
271
272 272 # Retrieves the date range based on predefined ranges or specific from/to param dates
273 273 def retrieve_date_range
274 274 @free_period = false
@@ -309,7 +309,7 private
309 309 else
310 310 # default
311 311 end
312
312
313 313 @from, @to = @to, @from if @from && @to && @from > @to
314 314 @from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
315 315 @to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
General Comments 0
You need to be logged in to leave comments. Login now