##// END OF EJS Templates
remove trailing white-spaces from issues controller source....
Toshi MARUYAMA -
r5703:4eb3af53d00f
parent child
Show More
@@ -1,335 +1,335
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
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.
17
17
18 class IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 menu_item :new_issue, :only => [:new, :create]
19 menu_item :new_issue, :only => [:new, :create]
20 default_search_scope :issues
20 default_search_scope :issues
21
21
22 before_filter :find_issue, :only => [:show, :edit, :update]
22 before_filter :find_issue, :only => [:show, :edit, :update]
23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
24 before_filter :check_project_uniqueness, :only => [:move, :perform_move]
24 before_filter :check_project_uniqueness, :only => [:move, :perform_move]
25 before_filter :find_project, :only => [:new, :create]
25 before_filter :find_project, :only => [:new, :create]
26 before_filter :authorize, :except => [:index]
26 before_filter :authorize, :except => [:index]
27 before_filter :find_optional_project, :only => [:index]
27 before_filter :find_optional_project, :only => [:index]
28 before_filter :check_for_default_issue_status, :only => [:new, :create]
28 before_filter :check_for_default_issue_status, :only => [:new, :create]
29 before_filter :build_new_issue_from_params, :only => [:new, :create]
29 before_filter :build_new_issue_from_params, :only => [:new, :create]
30 accept_key_auth :index, :show, :create, :update, :destroy
30 accept_key_auth :index, :show, :create, :update, :destroy
31
31
32 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
32 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
33
33
34 helper :journals
34 helper :journals
35 helper :projects
35 helper :projects
36 include ProjectsHelper
36 include ProjectsHelper
37 helper :custom_fields
37 helper :custom_fields
38 include CustomFieldsHelper
38 include CustomFieldsHelper
39 helper :issue_relations
39 helper :issue_relations
40 include IssueRelationsHelper
40 include IssueRelationsHelper
41 helper :watchers
41 helper :watchers
42 include WatchersHelper
42 include WatchersHelper
43 helper :attachments
43 helper :attachments
44 include AttachmentsHelper
44 include AttachmentsHelper
45 helper :queries
45 helper :queries
46 include QueriesHelper
46 include QueriesHelper
47 helper :repositories
47 helper :repositories
48 include RepositoriesHelper
48 include RepositoriesHelper
49 helper :sort
49 helper :sort
50 include SortHelper
50 include SortHelper
51 include IssuesHelper
51 include IssuesHelper
52 helper :timelog
52 helper :timelog
53 helper :gantt
53 helper :gantt
54 include Redmine::Export::PDF
54 include Redmine::Export::PDF
55
55
56 verify :method => [:post, :delete],
56 verify :method => [:post, :delete],
57 :only => :destroy,
57 :only => :destroy,
58 :render => { :nothing => true, :status => :method_not_allowed }
58 :render => { :nothing => true, :status => :method_not_allowed }
59
59
60 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
60 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
61 verify :method => :post, :only => :bulk_update, :render => {:nothing => true, :status => :method_not_allowed }
61 verify :method => :post, :only => :bulk_update, :render => {:nothing => true, :status => :method_not_allowed }
62 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
62 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
63
63
64 def index
64 def index
65 retrieve_query
65 retrieve_query
66 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
66 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
67 sort_update(@query.sortable_columns)
67 sort_update(@query.sortable_columns)
68
68
69 if @query.valid?
69 if @query.valid?
70 case params[:format]
70 case params[:format]
71 when 'csv', 'pdf'
71 when 'csv', 'pdf'
72 @limit = Setting.issues_export_limit.to_i
72 @limit = Setting.issues_export_limit.to_i
73 when 'atom'
73 when 'atom'
74 @limit = Setting.feeds_limit.to_i
74 @limit = Setting.feeds_limit.to_i
75 when 'xml', 'json'
75 when 'xml', 'json'
76 @offset, @limit = api_offset_and_limit
76 @offset, @limit = api_offset_and_limit
77 else
77 else
78 @limit = per_page_option
78 @limit = per_page_option
79 end
79 end
80
80
81 @issue_count = @query.issue_count
81 @issue_count = @query.issue_count
82 @issue_pages = Paginator.new self, @issue_count, @limit, params['page']
82 @issue_pages = Paginator.new self, @issue_count, @limit, params['page']
83 @offset ||= @issue_pages.current.offset
83 @offset ||= @issue_pages.current.offset
84 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
84 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
85 :order => sort_clause,
85 :order => sort_clause,
86 :offset => @offset,
86 :offset => @offset,
87 :limit => @limit)
87 :limit => @limit)
88 @issue_count_by_group = @query.issue_count_by_group
88 @issue_count_by_group = @query.issue_count_by_group
89
89
90 respond_to do |format|
90 respond_to do |format|
91 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
91 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
92 format.api
92 format.api
93 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
93 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
94 format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
94 format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
95 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
95 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
96 end
96 end
97 else
97 else
98 # Send html if the query is not valid
98 # Send html if the query is not valid
99 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
99 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
100 end
100 end
101 rescue ActiveRecord::RecordNotFound
101 rescue ActiveRecord::RecordNotFound
102 render_404
102 render_404
103 end
103 end
104
104
105 def show
105 def show
106 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
106 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
107 @journals.each_with_index {|j,i| j.indice = i+1}
107 @journals.each_with_index {|j,i| j.indice = i+1}
108 @journals.reverse! if User.current.wants_comments_in_reverse_order?
108 @journals.reverse! if User.current.wants_comments_in_reverse_order?
109
109
110 if User.current.allowed_to?(:view_changesets, @project)
110 if User.current.allowed_to?(:view_changesets, @project)
111 @changesets = @issue.changesets.visible.all
111 @changesets = @issue.changesets.visible.all
112 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
112 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
113 end
113 end
114
114
115 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
115 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
116 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
116 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
117 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
117 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
118 @priorities = IssuePriority.all
118 @priorities = IssuePriority.all
119 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
119 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
120 respond_to do |format|
120 respond_to do |format|
121 format.html { render :template => 'issues/show.rhtml' }
121 format.html { render :template => 'issues/show.rhtml' }
122 format.api
122 format.api
123 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
123 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
124 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
124 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
125 end
125 end
126 end
126 end
127
127
128 # Add a new issue
128 # Add a new issue
129 # The new issue will be created from an existing one if copy_from parameter is given
129 # The new issue will be created from an existing one if copy_from parameter is given
130 def new
130 def new
131 respond_to do |format|
131 respond_to do |format|
132 format.html { render :action => 'new', :layout => !request.xhr? }
132 format.html { render :action => 'new', :layout => !request.xhr? }
133 format.js { render :partial => 'attributes' }
133 format.js { render :partial => 'attributes' }
134 end
134 end
135 end
135 end
136
136
137 def create
137 def create
138 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
138 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
139 if @issue.save
139 if @issue.save
140 attachments = Attachment.attach_files(@issue, params[:attachments])
140 attachments = Attachment.attach_files(@issue, params[:attachments])
141 render_attachment_warning_if_needed(@issue)
141 render_attachment_warning_if_needed(@issue)
142 flash[:notice] = l(:notice_successful_create)
142 flash[:notice] = l(:notice_successful_create)
143 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
143 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
144 respond_to do |format|
144 respond_to do |format|
145 format.html {
145 format.html {
146 redirect_to(params[:continue] ? { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
146 redirect_to(params[:continue] ? { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
147 { :action => 'show', :id => @issue })
147 { :action => 'show', :id => @issue })
148 }
148 }
149 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
149 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
150 end
150 end
151 return
151 return
152 else
152 else
153 respond_to do |format|
153 respond_to do |format|
154 format.html { render :action => 'new' }
154 format.html { render :action => 'new' }
155 format.api { render_validation_errors(@issue) }
155 format.api { render_validation_errors(@issue) }
156 end
156 end
157 end
157 end
158 end
158 end
159
159
160 def edit
160 def edit
161 update_issue_from_params
161 update_issue_from_params
162
162
163 @journal = @issue.current_journal
163 @journal = @issue.current_journal
164
164
165 respond_to do |format|
165 respond_to do |format|
166 format.html { }
166 format.html { }
167 format.xml { }
167 format.xml { }
168 end
168 end
169 end
169 end
170
170
171 def update
171 def update
172 update_issue_from_params
172 update_issue_from_params
173
173
174 if @issue.save_issue_with_child_records(params, @time_entry)
174 if @issue.save_issue_with_child_records(params, @time_entry)
175 render_attachment_warning_if_needed(@issue)
175 render_attachment_warning_if_needed(@issue)
176 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
176 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
177
177
178 respond_to do |format|
178 respond_to do |format|
179 format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
179 format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
180 format.api { head :ok }
180 format.api { head :ok }
181 end
181 end
182 else
182 else
183 render_attachment_warning_if_needed(@issue)
183 render_attachment_warning_if_needed(@issue)
184 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
184 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
185 @journal = @issue.current_journal
185 @journal = @issue.current_journal
186
186
187 respond_to do |format|
187 respond_to do |format|
188 format.html { render :action => 'edit' }
188 format.html { render :action => 'edit' }
189 format.api { render_validation_errors(@issue) }
189 format.api { render_validation_errors(@issue) }
190 end
190 end
191 end
191 end
192 end
192 end
193
193
194 # Bulk edit a set of issues
194 # Bulk edit a set of issues
195 def bulk_edit
195 def bulk_edit
196 @issues.sort!
196 @issues.sort!
197 @available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w}
197 @available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w}
198 @custom_fields = @projects.map{|p|p.all_issue_custom_fields}.inject{|memo,c|memo & c}
198 @custom_fields = @projects.map{|p|p.all_issue_custom_fields}.inject{|memo,c|memo & c}
199 @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
199 @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
200 @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
200 @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
201 end
201 end
202
202
203 def bulk_update
203 def bulk_update
204 @issues.sort!
204 @issues.sort!
205 attributes = parse_params_for_bulk_issue_attributes(params)
205 attributes = parse_params_for_bulk_issue_attributes(params)
206
206
207 unsaved_issue_ids = []
207 unsaved_issue_ids = []
208 @issues.each do |issue|
208 @issues.each do |issue|
209 issue.reload
209 issue.reload
210 journal = issue.init_journal(User.current, params[:notes])
210 journal = issue.init_journal(User.current, params[:notes])
211 issue.safe_attributes = attributes
211 issue.safe_attributes = attributes
212 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
212 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
213 unless issue.save
213 unless issue.save
214 # Keep unsaved issue ids to display them in flash error
214 # Keep unsaved issue ids to display them in flash error
215 unsaved_issue_ids << issue.id
215 unsaved_issue_ids << issue.id
216 end
216 end
217 end
217 end
218 set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
218 set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
219 redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
219 redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
220 end
220 end
221
221
222 def destroy
222 def destroy
223 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
223 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
224 if @hours > 0
224 if @hours > 0
225 case params[:todo]
225 case params[:todo]
226 when 'destroy'
226 when 'destroy'
227 # nothing to do
227 # nothing to do
228 when 'nullify'
228 when 'nullify'
229 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
229 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
230 when 'reassign'
230 when 'reassign'
231 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
231 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
232 if reassign_to.nil?
232 if reassign_to.nil?
233 flash.now[:error] = l(:error_issue_not_found_in_project)
233 flash.now[:error] = l(:error_issue_not_found_in_project)
234 return
234 return
235 else
235 else
236 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
236 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
237 end
237 end
238 else
238 else
239 # display the destroy form if it's a user request
239 # display the destroy form if it's a user request
240 return unless api_request?
240 return unless api_request?
241 end
241 end
242 end
242 end
243 @issues.each do |issue|
243 @issues.each do |issue|
244 begin
244 begin
245 issue.reload.destroy
245 issue.reload.destroy
246 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
246 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
247 # nothing to do, issue was already deleted (eg. by a parent)
247 # nothing to do, issue was already deleted (eg. by a parent)
248 end
248 end
249 end
249 end
250 respond_to do |format|
250 respond_to do |format|
251 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
251 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
252 format.api { head :ok }
252 format.api { head :ok }
253 end
253 end
254 end
254 end
255
255
256 private
256 private
257 def find_issue
257 def find_issue
258 # Issue.visible.find(...) can not be used to redirect user to the login form
258 # Issue.visible.find(...) can not be used to redirect user to the login form
259 # if the issue actually exists but requires authentication
259 # if the issue actually exists but requires authentication
260 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
260 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
261 unless @issue.visible?
261 unless @issue.visible?
262 deny_access
262 deny_access
263 return
263 return
264 end
264 end
265 @project = @issue.project
265 @project = @issue.project
266 rescue ActiveRecord::RecordNotFound
266 rescue ActiveRecord::RecordNotFound
267 render_404
267 render_404
268 end
268 end
269
269
270 def find_project
270 def find_project
271 project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
271 project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
272 @project = Project.find(project_id)
272 @project = Project.find(project_id)
273 rescue ActiveRecord::RecordNotFound
273 rescue ActiveRecord::RecordNotFound
274 render_404
274 render_404
275 end
275 end
276
276
277 # Used by #edit and #update to set some common instance variables
277 # Used by #edit and #update to set some common instance variables
278 # from the params
278 # from the params
279 # TODO: Refactor, not everything in here is needed by #edit
279 # TODO: Refactor, not everything in here is needed by #edit
280 def update_issue_from_params
280 def update_issue_from_params
281 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
281 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
282 @priorities = IssuePriority.all
282 @priorities = IssuePriority.all
283 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
283 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
284 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
284 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
285 @time_entry.attributes = params[:time_entry]
285 @time_entry.attributes = params[:time_entry]
286
286
287 @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
287 @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
288 @issue.init_journal(User.current, @notes)
288 @issue.init_journal(User.current, @notes)
289 @issue.safe_attributes = params[:issue]
289 @issue.safe_attributes = params[:issue]
290 end
290 end
291
291
292 # TODO: Refactor, lots of extra code in here
292 # TODO: Refactor, lots of extra code in here
293 # TODO: Changing tracker on an existing issue should not trigger this
293 # TODO: Changing tracker on an existing issue should not trigger this
294 def build_new_issue_from_params
294 def build_new_issue_from_params
295 if params[:id].blank?
295 if params[:id].blank?
296 @issue = Issue.new
296 @issue = Issue.new
297 @issue.copy_from(params[:copy_from]) if params[:copy_from]
297 @issue.copy_from(params[:copy_from]) if params[:copy_from]
298 @issue.project = @project
298 @issue.project = @project
299 else
299 else
300 @issue = @project.issues.visible.find(params[:id])
300 @issue = @project.issues.visible.find(params[:id])
301 end
301 end
302
302
303 @issue.project = @project
303 @issue.project = @project
304 # Tracker must be set before custom field values
304 # Tracker must be set before custom field values
305 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
305 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
306 if @issue.tracker.nil?
306 if @issue.tracker.nil?
307 render_error l(:error_no_tracker_in_project)
307 render_error l(:error_no_tracker_in_project)
308 return false
308 return false
309 end
309 end
310 @issue.start_date ||= Date.today
310 @issue.start_date ||= Date.today
311 if params[:issue].is_a?(Hash)
311 if params[:issue].is_a?(Hash)
312 @issue.safe_attributes = params[:issue]
312 @issue.safe_attributes = params[:issue]
313 if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record?
313 if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record?
314 @issue.watcher_user_ids = params[:issue]['watcher_user_ids']
314 @issue.watcher_user_ids = params[:issue]['watcher_user_ids']
315 end
315 end
316 end
316 end
317 @issue.author = User.current
317 @issue.author = User.current
318 @priorities = IssuePriority.all
318 @priorities = IssuePriority.all
319 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
319 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
320 end
320 end
321
321
322 def check_for_default_issue_status
322 def check_for_default_issue_status
323 if IssueStatus.default.nil?
323 if IssueStatus.default.nil?
324 render_error l(:error_no_default_issue_status)
324 render_error l(:error_no_default_issue_status)
325 return false
325 return false
326 end
326 end
327 end
327 end
328
328
329 def parse_params_for_bulk_issue_attributes(params)
329 def parse_params_for_bulk_issue_attributes(params)
330 attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
330 attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
331 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
331 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
332 attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
332 attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
333 attributes
333 attributes
334 end
334 end
335 end
335 end
General Comments 0
You need to be logged in to leave comments. Login now