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