Mercurial > hg > soundsoftware-site
comparison app/controllers/issues_controller.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 0c939c159af4 |
children | 5e80956cc792 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
87 :offset => @offset, | 87 :offset => @offset, |
88 :limit => @limit) | 88 :limit => @limit) |
89 @issue_count_by_group = @query.issue_count_by_group | 89 @issue_count_by_group = @query.issue_count_by_group |
90 | 90 |
91 respond_to do |format| | 91 respond_to do |format| |
92 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? } | 92 format.html { render :template => 'issues/index', :layout => !request.xhr? } |
93 format.api | 93 format.api { |
94 Issue.load_relations(@issues) if include_in_api_response?('relations') | |
95 } | |
94 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } | 96 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } |
95 format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') } | 97 format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') } |
96 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') } | 98 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') } |
97 end | 99 end |
98 else | 100 else |
99 # Send html if the query is not valid | 101 respond_to do |format| |
100 render(:template => 'issues/index.rhtml', :layout => !request.xhr?) | 102 format.html { render(:template => 'issues/index', :layout => !request.xhr?) } |
103 format.any(:atom, :csv, :pdf) { render(:nothing => true) } | |
104 format.api { render_validation_errors(@query) } | |
105 end | |
101 end | 106 end |
102 rescue ActiveRecord::RecordNotFound | 107 rescue ActiveRecord::RecordNotFound |
103 render_404 | 108 render_404 |
104 end | 109 end |
105 | 110 |
114 end | 119 end |
115 | 120 |
116 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } | 121 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
117 @allowed_statuses = @issue.new_statuses_allowed_to(User.current) | 122 @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
118 @edit_allowed = User.current.allowed_to?(:edit_issues, @project) | 123 @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
119 @priorities = IssuePriority.all | 124 @priorities = IssuePriority.active |
120 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) | 125 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
121 respond_to do |format| | 126 respond_to do |format| |
122 format.html { render :template => 'issues/show.rhtml' } | 127 format.html { render :template => 'issues/show' } |
123 format.api | 128 format.api |
124 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } | 129 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } |
125 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") } | 130 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") } |
126 end | 131 end |
127 end | 132 end |
137 | 142 |
138 def create | 143 def create |
139 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) | 144 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) |
140 if @issue.save | 145 if @issue.save |
141 attachments = Attachment.attach_files(@issue, params[:attachments]) | 146 attachments = Attachment.attach_files(@issue, params[:attachments]) |
142 render_attachment_warning_if_needed(@issue) | |
143 flash[:notice] = l(:notice_successful_create) | |
144 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) | 147 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) |
145 respond_to do |format| | 148 respond_to do |format| |
146 format.html { | 149 format.html { |
150 render_attachment_warning_if_needed(@issue) | |
151 flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>") | |
147 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?} } : | 152 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?} } : |
148 { :action => 'show', :id => @issue }) | 153 { :action => 'show', :id => @issue }) |
149 } | 154 } |
150 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } | 155 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } |
151 end | 156 end |
278 # Used by #edit and #update to set some common instance variables | 283 # Used by #edit and #update to set some common instance variables |
279 # from the params | 284 # from the params |
280 # TODO: Refactor, not everything in here is needed by #edit | 285 # TODO: Refactor, not everything in here is needed by #edit |
281 def update_issue_from_params | 286 def update_issue_from_params |
282 @allowed_statuses = @issue.new_statuses_allowed_to(User.current) | 287 @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
283 @priorities = IssuePriority.all | 288 @priorities = IssuePriority.active |
284 @edit_allowed = User.current.allowed_to?(:edit_issues, @project) | 289 @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
285 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) | 290 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
286 @time_entry.attributes = params[:time_entry] | 291 @time_entry.attributes = params[:time_entry] |
287 | 292 |
288 @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) | 293 @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) |
307 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) | 312 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |
308 if @issue.tracker.nil? | 313 if @issue.tracker.nil? |
309 render_error l(:error_no_tracker_in_project) | 314 render_error l(:error_no_tracker_in_project) |
310 return false | 315 return false |
311 end | 316 end |
312 @issue.start_date ||= Date.today | 317 @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date? |
313 if params[:issue].is_a?(Hash) | 318 if params[:issue].is_a?(Hash) |
314 @issue.safe_attributes = params[:issue] | 319 @issue.safe_attributes = params[:issue] |
315 if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record? | 320 if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record? |
316 @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] | 321 @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] |
317 end | 322 end |
318 end | 323 end |
319 @priorities = IssuePriority.all | 324 @priorities = IssuePriority.active |
320 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) | 325 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) |
321 end | 326 end |
322 | 327 |
323 def check_for_default_issue_status | 328 def check_for_default_issue_status |
324 if IssueStatus.default.nil? | 329 if IssueStatus.default.nil? |