Mercurial > hg > soundsoftware-site
comparison app/controllers/issues_controller.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 433d4f72a19b |
children | 4f746d8966dd |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 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. |
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, :destroy] | 23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] |
24 before_filter :find_project, :only => [:new, :create] | 24 before_filter :find_project, :only => [:new, :create, :update_form] |
25 before_filter :authorize, :except => [:index] | 25 before_filter :authorize, :except => [:index] |
26 before_filter :find_optional_project, :only => [:index] | 26 before_filter :find_optional_project, :only => [:index] |
27 before_filter :check_for_default_issue_status, :only => [:new, :create] | 27 before_filter :check_for_default_issue_status, :only => [:new, :create] |
28 before_filter :build_new_issue_from_params, :only => [:new, :create] | 28 before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form] |
29 accept_rss_auth :index, :show | 29 accept_rss_auth :index, :show |
30 accept_api_auth :index, :show, :create, :update, :destroy | 30 accept_api_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 |
69 else | 69 else |
70 @limit = per_page_option | 70 @limit = per_page_option |
71 end | 71 end |
72 | 72 |
73 @issue_count = @query.issue_count | 73 @issue_count = @query.issue_count |
74 @issue_pages = Paginator.new self, @issue_count, @limit, params['page'] | 74 @issue_pages = Paginator.new @issue_count, @limit, params['page'] |
75 @offset ||= @issue_pages.current.offset | 75 @offset ||= @issue_pages.offset |
76 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], | 76 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], |
77 :order => sort_clause, | 77 :order => sort_clause, |
78 :offset => @offset, | 78 :offset => @offset, |
79 :limit => @limit) | 79 :limit => @limit) |
80 @issue_count_by_group = @query.issue_count_by_group | 80 @issue_count_by_group = @query.issue_count_by_group |
83 format.html { render :template => 'issues/index', :layout => !request.xhr? } | 83 format.html { render :template => 'issues/index', :layout => !request.xhr? } |
84 format.api { | 84 format.api { |
85 Issue.load_visible_relations(@issues) if include_in_api_response?('relations') | 85 Issue.load_visible_relations(@issues) if include_in_api_response?('relations') |
86 } | 86 } |
87 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } | 87 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } |
88 format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') } | 88 format.csv { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') } |
89 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') } | 89 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'issues.pdf') } |
90 end | 90 end |
91 else | 91 else |
92 respond_to do |format| | 92 respond_to do |format| |
93 format.html { render(:template => 'issues/index', :layout => !request.xhr?) } | 93 format.html { render(:template => 'issues/index', :layout => !request.xhr?) } |
94 format.any(:atom, :csv, :pdf) { render(:nothing => true) } | 94 format.any(:atom, :csv, :pdf) { render(:nothing => true) } |
130 # Add a new issue | 130 # Add a new issue |
131 # The new issue will be created from an existing one if copy_from parameter is given | 131 # The new issue will be created from an existing one if copy_from parameter is given |
132 def new | 132 def new |
133 respond_to do |format| | 133 respond_to do |format| |
134 format.html { render :action => 'new', :layout => !request.xhr? } | 134 format.html { render :action => 'new', :layout => !request.xhr? } |
135 format.js { render :partial => 'update_form' } | |
136 end | 135 end |
137 end | 136 end |
138 | 137 |
139 def create | 138 def create |
140 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) | 139 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) |
143 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) | 142 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) |
144 respond_to do |format| | 143 respond_to do |format| |
145 format.html { | 144 format.html { |
146 render_attachment_warning_if_needed(@issue) | 145 render_attachment_warning_if_needed(@issue) |
147 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject)) | 146 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject)) |
148 redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } : | 147 if params[:continue] |
149 { :action => 'show', :id => @issue }) | 148 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} |
149 redirect_to new_project_issue_path(@issue.project, :issue => attrs) | |
150 else | |
151 redirect_to issue_path(@issue) | |
152 end | |
150 } | 153 } |
151 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } | 154 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } |
152 end | 155 end |
153 return | 156 return |
154 else | 157 else |
185 if saved | 188 if saved |
186 render_attachment_warning_if_needed(@issue) | 189 render_attachment_warning_if_needed(@issue) |
187 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? | 190 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? |
188 | 191 |
189 respond_to do |format| | 192 respond_to do |format| |
190 format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } | 193 format.html { redirect_back_or_default issue_path(@issue) } |
191 format.api { render_api_ok } | 194 format.api { render_api_ok } |
192 end | 195 end |
193 else | 196 else |
194 respond_to do |format| | 197 respond_to do |format| |
195 format.html { render :action => 'edit' } | 198 format.html { render :action => 'edit' } |
196 format.api { render_validation_errors(@issue) } | 199 format.api { render_validation_errors(@issue) } |
197 end | 200 end |
198 end | 201 end |
202 end | |
203 | |
204 # Updates the issue form when changing the project, status or tracker | |
205 # on issue creation/update | |
206 def update_form | |
199 end | 207 end |
200 | 208 |
201 # Bulk edit/copy a set of issues | 209 # Bulk edit/copy a set of issues |
202 def bulk_edit | 210 def bulk_edit |
203 @issues.sort! | 211 @issues.sort! |
268 end | 276 end |
269 set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) | 277 set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) |
270 | 278 |
271 if params[:follow] | 279 if params[:follow] |
272 if @issues.size == 1 && moved_issues.size == 1 | 280 if @issues.size == 1 && moved_issues.size == 1 |
273 redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first | 281 redirect_to issue_path(moved_issues.first) |
274 elsif moved_issues.map(&:project).uniq.size == 1 | 282 elsif moved_issues.map(&:project).uniq.size == 1 |
275 redirect_to :controller => 'issues', :action => 'index', :project_id => moved_issues.map(&:project).first | 283 redirect_to project_issues_path(moved_issues.map(&:project).first) |
276 end | 284 end |
277 else | 285 else |
278 redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) | 286 redirect_back_or_default _project_issues_path(@project) |
279 end | 287 end |
280 end | 288 end |
281 | 289 |
282 def destroy | 290 def destroy |
283 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f | 291 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f |
306 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists | 314 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists |
307 # nothing to do, issue was already deleted (eg. by a parent) | 315 # nothing to do, issue was already deleted (eg. by a parent) |
308 end | 316 end |
309 end | 317 end |
310 respond_to do |format| | 318 respond_to do |format| |
311 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } | 319 format.html { redirect_back_or_default _project_issues_path(@project) } |
312 format.api { render_api_ok } | 320 format.api { render_api_ok } |
313 end | 321 end |
314 end | 322 end |
315 | 323 |
316 private | 324 private |