Mercurial > hg > soundsoftware-site
comparison app/controllers/.svn/text-base/issues_controller.rb.svn-base @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 94944d00e43c |
children | 0579821a129a |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 119:8661b858af72 |
---|---|
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 | |
48 include RepositoriesHelper | |
47 helper :sort | 49 helper :sort |
48 include SortHelper | 50 include SortHelper |
49 include IssuesHelper | 51 include IssuesHelper |
50 helper :timelog | 52 helper :timelog |
51 helper :gantt | 53 helper :gantt |
63 retrieve_query | 65 retrieve_query |
64 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) | 66 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) |
65 sort_update(@query.sortable_columns) | 67 sort_update(@query.sortable_columns) |
66 | 68 |
67 if @query.valid? | 69 if @query.valid? |
68 limit = case params[:format] | 70 case params[:format] |
69 when 'csv', 'pdf' | 71 when 'csv', 'pdf' |
70 Setting.issues_export_limit.to_i | 72 @limit = Setting.issues_export_limit.to_i |
71 when 'atom' | 73 when 'atom' |
72 Setting.feeds_limit.to_i | 74 @limit = Setting.feeds_limit.to_i |
75 when 'xml', 'json' | |
76 @offset, @limit = api_offset_and_limit | |
73 else | 77 else |
74 per_page_option | 78 @limit = per_page_option |
75 end | 79 end |
76 | 80 |
77 @issue_count = @query.issue_count | 81 @issue_count = @query.issue_count |
78 @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 | |
79 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], | 84 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], |
80 :order => sort_clause, | 85 :order => sort_clause, |
81 :offset => @issue_pages.current.offset, | 86 :offset => @offset, |
82 :limit => limit) | 87 :limit => @limit) |
83 @issue_count_by_group = @query.issue_count_by_group | 88 @issue_count_by_group = @query.issue_count_by_group |
84 | 89 |
85 respond_to do |format| | 90 respond_to do |format| |
86 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? } | 91 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? } |
87 format.xml { render :layout => false } | 92 format.api |
88 format.json { render :text => @issues.to_json, :layout => false } | |
89 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)}") } |
90 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') } |
91 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') } |
92 end | 96 end |
93 else | 97 else |
108 @edit_allowed = User.current.allowed_to?(:edit_issues, @project) | 112 @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
109 @priorities = IssuePriority.all | 113 @priorities = IssuePriority.all |
110 @time_entry = TimeEntry.new | 114 @time_entry = TimeEntry.new |
111 respond_to do |format| | 115 respond_to do |format| |
112 format.html { render :template => 'issues/show.rhtml' } | 116 format.html { render :template => 'issues/show.rhtml' } |
113 format.xml { render :layout => false } | 117 format.api |
114 format.json { render :text => @issue.to_json, :layout => false } | |
115 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } | 118 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } |
116 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") } | 119 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") } |
117 end | 120 end |
118 end | 121 end |
119 | 122 |
136 respond_to do |format| | 139 respond_to do |format| |
137 format.html { | 140 format.html { |
138 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?} } : | 141 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?} } : |
139 { :action => 'show', :id => @issue }) | 142 { :action => 'show', :id => @issue }) |
140 } | 143 } |
141 format.xml { render :action => 'show', :status => :created, :location => url_for(:controller => 'issues', :action => 'show', :id => @issue) } | 144 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } |
142 format.json { render :text => @issue.to_json, :status => :created, :location => url_for(:controller => 'issues', :action => 'show'), :layout => false } | |
143 end | 145 end |
144 return | 146 return |
145 else | 147 else |
146 respond_to do |format| | 148 respond_to do |format| |
147 format.html { render :action => 'new' } | 149 format.html { render :action => 'new' } |
148 format.xml { render(:xml => @issue.errors, :status => :unprocessable_entity); return } | 150 format.api { render_validation_errors(@issue) } |
149 format.json { render :text => object_errors_to_json(@issue), :status => :unprocessable_entity, :layout => false } | |
150 end | 151 end |
151 end | 152 end |
152 end | 153 end |
153 | 154 |
154 def edit | 155 def edit |
169 render_attachment_warning_if_needed(@issue) | 170 render_attachment_warning_if_needed(@issue) |
170 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? | 171 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? |
171 | 172 |
172 respond_to do |format| | 173 respond_to do |format| |
173 format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } | 174 format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } |
174 format.xml { head :ok } | 175 format.api { head :ok } |
175 format.json { head :ok } | |
176 end | 176 end |
177 else | 177 else |
178 render_attachment_warning_if_needed(@issue) | 178 render_attachment_warning_if_needed(@issue) |
179 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? | 179 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? |
180 @journal = @issue.current_journal | 180 @journal = @issue.current_journal |
181 | 181 |
182 respond_to do |format| | 182 respond_to do |format| |
183 format.html { render :action => 'edit' } | 183 format.html { render :action => 'edit' } |
184 format.xml { render :xml => @issue.errors, :status => :unprocessable_entity } | 184 format.api { render_validation_errors(@issue) } |
185 format.json { render :text => object_errors_to_json(@issue), :status => :unprocessable_entity, :layout => false } | |
186 end | 185 end |
187 end | 186 end |
188 end | 187 end |
189 | 188 |
190 # Bulk edit a set of issues | 189 # Bulk edit a set of issues |
230 return | 229 return |
231 else | 230 else |
232 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) | 231 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) |
233 end | 232 end |
234 else | 233 else |
235 unless params[:format] == 'xml' || params[:format] == 'json' | 234 # display the destroy form if it's a user request |
236 # display the destroy form if it's a user request | 235 return unless api_request? |
237 return | |
238 end | |
239 end | 236 end |
240 end | 237 end |
241 @issues.each(&:destroy) | 238 @issues.each(&:destroy) |
242 respond_to do |format| | 239 respond_to do |format| |
243 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } | 240 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } |
244 format.xml { head :ok } | 241 format.api { head :ok } |
245 format.json { head :ok } | |
246 end | 242 end |
247 end | 243 end |
248 | 244 |
249 private | 245 private |
250 def find_issue | 246 def find_issue |