@@ -1,316 +1,318 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 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 | |||
|
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 | |
52 | include Redmine::Export::PDF |
|
54 | include Redmine::Export::PDF | |
53 |
|
55 | |||
54 | verify :method => [:post, :delete], |
|
56 | verify :method => [:post, :delete], | |
55 | :only => :destroy, |
|
57 | :only => :destroy, | |
56 | :render => { :nothing => true, :status => :method_not_allowed } |
|
58 | :render => { :nothing => true, :status => :method_not_allowed } | |
57 |
|
59 | |||
58 | 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 } | |
59 | 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 } | |
60 | 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 } | |
61 |
|
63 | |||
62 | def index |
|
64 | def index | |
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 | case params[:format] |
|
70 | case params[:format] | |
69 | when 'csv', 'pdf' |
|
71 | when 'csv', 'pdf' | |
70 | @limit = Setting.issues_export_limit.to_i |
|
72 | @limit = Setting.issues_export_limit.to_i | |
71 | when 'atom' |
|
73 | when 'atom' | |
72 | @limit = Setting.feeds_limit.to_i |
|
74 | @limit = Setting.feeds_limit.to_i | |
73 | when 'xml', 'json' |
|
75 | when 'xml', 'json' | |
74 | @offset, @limit = api_offset_and_limit |
|
76 | @offset, @limit = api_offset_and_limit | |
75 | else |
|
77 | else | |
76 | @limit = per_page_option |
|
78 | @limit = per_page_option | |
77 | end |
|
79 | end | |
78 |
|
80 | |||
79 | @issue_count = @query.issue_count |
|
81 | @issue_count = @query.issue_count | |
80 | @issue_pages = Paginator.new self, @issue_count, @limit, params['page'] |
|
82 | @issue_pages = Paginator.new self, @issue_count, @limit, params['page'] | |
81 | @offset ||= @issue_pages.current.offset |
|
83 | @offset ||= @issue_pages.current.offset | |
82 | @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], |
|
84 | @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], | |
83 | :order => sort_clause, |
|
85 | :order => sort_clause, | |
84 | :offset => @offset, |
|
86 | :offset => @offset, | |
85 | :limit => @limit) |
|
87 | :limit => @limit) | |
86 | @issue_count_by_group = @query.issue_count_by_group |
|
88 | @issue_count_by_group = @query.issue_count_by_group | |
87 |
|
89 | |||
88 | respond_to do |format| |
|
90 | respond_to do |format| | |
89 | format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? } |
|
91 | format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? } | |
90 | format.api |
|
92 | format.api | |
91 | 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)}") } | |
92 | 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') } | |
93 | 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') } | |
94 | end |
|
96 | end | |
95 | else |
|
97 | else | |
96 | # Send html if the query is not valid |
|
98 | # Send html if the query is not valid | |
97 | render(:template => 'issues/index.rhtml', :layout => !request.xhr?) |
|
99 | render(:template => 'issues/index.rhtml', :layout => !request.xhr?) | |
98 | end |
|
100 | end | |
99 | rescue ActiveRecord::RecordNotFound |
|
101 | rescue ActiveRecord::RecordNotFound | |
100 | render_404 |
|
102 | render_404 | |
101 | end |
|
103 | end | |
102 |
|
104 | |||
103 | def show |
|
105 | def show | |
104 | @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") | |
105 | @journals.each_with_index {|j,i| j.indice = i+1} |
|
107 | @journals.each_with_index {|j,i| j.indice = i+1} | |
106 | @journals.reverse! if User.current.wants_comments_in_reverse_order? |
|
108 | @journals.reverse! if User.current.wants_comments_in_reverse_order? | |
107 | @changesets = @issue.changesets.visible.all |
|
109 | @changesets = @issue.changesets.visible.all | |
108 | @changesets.reverse! if User.current.wants_comments_in_reverse_order? |
|
110 | @changesets.reverse! if User.current.wants_comments_in_reverse_order? | |
109 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
|
111 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) | |
110 | @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
|
112 | @edit_allowed = User.current.allowed_to?(:edit_issues, @project) | |
111 | @priorities = IssuePriority.all |
|
113 | @priorities = IssuePriority.all | |
112 | @time_entry = TimeEntry.new |
|
114 | @time_entry = TimeEntry.new | |
113 | respond_to do |format| |
|
115 | respond_to do |format| | |
114 | format.html { render :template => 'issues/show.rhtml' } |
|
116 | format.html { render :template => 'issues/show.rhtml' } | |
115 | format.api |
|
117 | format.api | |
116 | 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' } | |
117 | 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") } | |
118 | end |
|
120 | end | |
119 | end |
|
121 | end | |
120 |
|
122 | |||
121 | # Add a new issue |
|
123 | # Add a new issue | |
122 | # The new issue will be created from an existing one if copy_from parameter is given |
|
124 | # The new issue will be created from an existing one if copy_from parameter is given | |
123 | def new |
|
125 | def new | |
124 | respond_to do |format| |
|
126 | respond_to do |format| | |
125 | format.html { render :action => 'new', :layout => !request.xhr? } |
|
127 | format.html { render :action => 'new', :layout => !request.xhr? } | |
126 | format.js { render :partial => 'attributes' } |
|
128 | format.js { render :partial => 'attributes' } | |
127 | end |
|
129 | end | |
128 | end |
|
130 | end | |
129 |
|
131 | |||
130 | def create |
|
132 | def create | |
131 | call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) |
|
133 | call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) | |
132 | if @issue.save |
|
134 | if @issue.save | |
133 | attachments = Attachment.attach_files(@issue, params[:attachments]) |
|
135 | attachments = Attachment.attach_files(@issue, params[:attachments]) | |
134 | render_attachment_warning_if_needed(@issue) |
|
136 | render_attachment_warning_if_needed(@issue) | |
135 | flash[:notice] = l(:notice_successful_create) |
|
137 | flash[:notice] = l(:notice_successful_create) | |
136 | call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) |
|
138 | call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) | |
137 | respond_to do |format| |
|
139 | respond_to do |format| | |
138 | format.html { |
|
140 | format.html { | |
139 | 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?} } : | |
140 | { :action => 'show', :id => @issue }) |
|
142 | { :action => 'show', :id => @issue }) | |
141 | } |
|
143 | } | |
142 | format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } |
|
144 | format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } | |
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.api { render_validation_errors(@issue) } |
|
150 | format.api { render_validation_errors(@issue) } | |
149 | end |
|
151 | end | |
150 | end |
|
152 | end | |
151 | end |
|
153 | end | |
152 |
|
154 | |||
153 | def edit |
|
155 | def edit | |
154 | update_issue_from_params |
|
156 | update_issue_from_params | |
155 |
|
157 | |||
156 | @journal = @issue.current_journal |
|
158 | @journal = @issue.current_journal | |
157 |
|
159 | |||
158 | respond_to do |format| |
|
160 | respond_to do |format| | |
159 | format.html { } |
|
161 | format.html { } | |
160 | format.xml { } |
|
162 | format.xml { } | |
161 | end |
|
163 | end | |
162 | end |
|
164 | end | |
163 |
|
165 | |||
164 | def update |
|
166 | def update | |
165 | update_issue_from_params |
|
167 | update_issue_from_params | |
166 |
|
168 | |||
167 | if @issue.save_issue_with_child_records(params, @time_entry) |
|
169 | if @issue.save_issue_with_child_records(params, @time_entry) | |
168 | render_attachment_warning_if_needed(@issue) |
|
170 | render_attachment_warning_if_needed(@issue) | |
169 | 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? | |
170 |
|
172 | |||
171 | respond_to do |format| |
|
173 | respond_to do |format| | |
172 | format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } |
|
174 | format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } | |
173 | format.api { head :ok } |
|
175 | format.api { head :ok } | |
174 | end |
|
176 | end | |
175 | else |
|
177 | else | |
176 | render_attachment_warning_if_needed(@issue) |
|
178 | render_attachment_warning_if_needed(@issue) | |
177 | 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? | |
178 | @journal = @issue.current_journal |
|
180 | @journal = @issue.current_journal | |
179 |
|
181 | |||
180 | respond_to do |format| |
|
182 | respond_to do |format| | |
181 | format.html { render :action => 'edit' } |
|
183 | format.html { render :action => 'edit' } | |
182 | format.api { render_validation_errors(@issue) } |
|
184 | format.api { render_validation_errors(@issue) } | |
183 | end |
|
185 | end | |
184 | end |
|
186 | end | |
185 | end |
|
187 | end | |
186 |
|
188 | |||
187 | # Bulk edit a set of issues |
|
189 | # Bulk edit a set of issues | |
188 | def bulk_edit |
|
190 | def bulk_edit | |
189 | @issues.sort! |
|
191 | @issues.sort! | |
190 | @available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w} |
|
192 | @available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w} | |
191 | @custom_fields = @projects.map{|p|p.all_issue_custom_fields}.inject{|memo,c|memo & c} |
|
193 | @custom_fields = @projects.map{|p|p.all_issue_custom_fields}.inject{|memo,c|memo & c} | |
192 | @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} |
|
194 | @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} | |
193 | @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} |
|
195 | @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} | |
194 | end |
|
196 | end | |
195 |
|
197 | |||
196 | def bulk_update |
|
198 | def bulk_update | |
197 | @issues.sort! |
|
199 | @issues.sort! | |
198 | attributes = parse_params_for_bulk_issue_attributes(params) |
|
200 | attributes = parse_params_for_bulk_issue_attributes(params) | |
199 |
|
201 | |||
200 | unsaved_issue_ids = [] |
|
202 | unsaved_issue_ids = [] | |
201 | @issues.each do |issue| |
|
203 | @issues.each do |issue| | |
202 | issue.reload |
|
204 | issue.reload | |
203 | journal = issue.init_journal(User.current, params[:notes]) |
|
205 | journal = issue.init_journal(User.current, params[:notes]) | |
204 | issue.safe_attributes = attributes |
|
206 | issue.safe_attributes = attributes | |
205 | call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) |
|
207 | call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) | |
206 | unless issue.save |
|
208 | unless issue.save | |
207 | # Keep unsaved issue ids to display them in flash error |
|
209 | # Keep unsaved issue ids to display them in flash error | |
208 | unsaved_issue_ids << issue.id |
|
210 | unsaved_issue_ids << issue.id | |
209 | end |
|
211 | end | |
210 | end |
|
212 | end | |
211 | set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) |
|
213 | set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) | |
212 | redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) |
|
214 | redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) | |
213 | end |
|
215 | end | |
214 |
|
216 | |||
215 | def destroy |
|
217 | def destroy | |
216 | @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f |
|
218 | @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f | |
217 | if @hours > 0 |
|
219 | if @hours > 0 | |
218 | case params[:todo] |
|
220 | case params[:todo] | |
219 | when 'destroy' |
|
221 | when 'destroy' | |
220 | # nothing to do |
|
222 | # nothing to do | |
221 | when 'nullify' |
|
223 | when 'nullify' | |
222 | TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) |
|
224 | TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) | |
223 | when 'reassign' |
|
225 | when 'reassign' | |
224 | reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) |
|
226 | reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) | |
225 | if reassign_to.nil? |
|
227 | if reassign_to.nil? | |
226 | flash.now[:error] = l(:error_issue_not_found_in_project) |
|
228 | flash.now[:error] = l(:error_issue_not_found_in_project) | |
227 | return |
|
229 | return | |
228 | else |
|
230 | else | |
229 | 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]) | |
230 | end |
|
232 | end | |
231 | else |
|
233 | else | |
232 | # display the destroy form if it's a user request |
|
234 | # display the destroy form if it's a user request | |
233 | return unless api_request? |
|
235 | return unless api_request? | |
234 | end |
|
236 | end | |
235 | end |
|
237 | end | |
236 | @issues.each(&:destroy) |
|
238 | @issues.each(&:destroy) | |
237 | respond_to do |format| |
|
239 | respond_to do |format| | |
238 | format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } |
|
240 | format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } | |
239 | format.api { head :ok } |
|
241 | format.api { head :ok } | |
240 | end |
|
242 | end | |
241 | end |
|
243 | end | |
242 |
|
244 | |||
243 | private |
|
245 | private | |
244 | def find_issue |
|
246 | def find_issue | |
245 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) |
|
247 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) | |
246 | @project = @issue.project |
|
248 | @project = @issue.project | |
247 | rescue ActiveRecord::RecordNotFound |
|
249 | rescue ActiveRecord::RecordNotFound | |
248 | render_404 |
|
250 | render_404 | |
249 | end |
|
251 | end | |
250 |
|
252 | |||
251 | def find_project |
|
253 | def find_project | |
252 | project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] |
|
254 | project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] | |
253 | @project = Project.find(project_id) |
|
255 | @project = Project.find(project_id) | |
254 | rescue ActiveRecord::RecordNotFound |
|
256 | rescue ActiveRecord::RecordNotFound | |
255 | render_404 |
|
257 | render_404 | |
256 | end |
|
258 | end | |
257 |
|
259 | |||
258 | # Used by #edit and #update to set some common instance variables |
|
260 | # Used by #edit and #update to set some common instance variables | |
259 | # from the params |
|
261 | # from the params | |
260 | # TODO: Refactor, not everything in here is needed by #edit |
|
262 | # TODO: Refactor, not everything in here is needed by #edit | |
261 | def update_issue_from_params |
|
263 | def update_issue_from_params | |
262 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
|
264 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) | |
263 | @priorities = IssuePriority.all |
|
265 | @priorities = IssuePriority.all | |
264 | @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
|
266 | @edit_allowed = User.current.allowed_to?(:edit_issues, @project) | |
265 | @time_entry = TimeEntry.new |
|
267 | @time_entry = TimeEntry.new | |
266 | @time_entry.attributes = params[:time_entry] |
|
268 | @time_entry.attributes = params[:time_entry] | |
267 |
|
269 | |||
268 | @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) |
|
270 | @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) | |
269 | @issue.init_journal(User.current, @notes) |
|
271 | @issue.init_journal(User.current, @notes) | |
270 | @issue.safe_attributes = params[:issue] |
|
272 | @issue.safe_attributes = params[:issue] | |
271 | end |
|
273 | end | |
272 |
|
274 | |||
273 | # TODO: Refactor, lots of extra code in here |
|
275 | # TODO: Refactor, lots of extra code in here | |
274 | # TODO: Changing tracker on an existing issue should not trigger this |
|
276 | # TODO: Changing tracker on an existing issue should not trigger this | |
275 | def build_new_issue_from_params |
|
277 | def build_new_issue_from_params | |
276 | if params[:id].blank? |
|
278 | if params[:id].blank? | |
277 | @issue = Issue.new |
|
279 | @issue = Issue.new | |
278 | @issue.copy_from(params[:copy_from]) if params[:copy_from] |
|
280 | @issue.copy_from(params[:copy_from]) if params[:copy_from] | |
279 | @issue.project = @project |
|
281 | @issue.project = @project | |
280 | else |
|
282 | else | |
281 | @issue = @project.issues.visible.find(params[:id]) |
|
283 | @issue = @project.issues.visible.find(params[:id]) | |
282 | end |
|
284 | end | |
283 |
|
285 | |||
284 | @issue.project = @project |
|
286 | @issue.project = @project | |
285 | # Tracker must be set before custom field values |
|
287 | # Tracker must be set before custom field values | |
286 | @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |
|
288 | @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) | |
287 | if @issue.tracker.nil? |
|
289 | if @issue.tracker.nil? | |
288 | render_error l(:error_no_tracker_in_project) |
|
290 | render_error l(:error_no_tracker_in_project) | |
289 | return false |
|
291 | return false | |
290 | end |
|
292 | end | |
291 | @issue.start_date ||= Date.today |
|
293 | @issue.start_date ||= Date.today | |
292 | if params[:issue].is_a?(Hash) |
|
294 | if params[:issue].is_a?(Hash) | |
293 | @issue.safe_attributes = params[:issue] |
|
295 | @issue.safe_attributes = params[:issue] | |
294 | if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record? |
|
296 | if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record? | |
295 | @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] |
|
297 | @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] | |
296 | end |
|
298 | end | |
297 | end |
|
299 | end | |
298 | @issue.author = User.current |
|
300 | @issue.author = User.current | |
299 | @priorities = IssuePriority.all |
|
301 | @priorities = IssuePriority.all | |
300 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) |
|
302 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) | |
301 | end |
|
303 | end | |
302 |
|
304 | |||
303 | def check_for_default_issue_status |
|
305 | def check_for_default_issue_status | |
304 | if IssueStatus.default.nil? |
|
306 | if IssueStatus.default.nil? | |
305 | render_error l(:error_no_default_issue_status) |
|
307 | render_error l(:error_no_default_issue_status) | |
306 | return false |
|
308 | return false | |
307 | end |
|
309 | end | |
308 | end |
|
310 | end | |
309 |
|
311 | |||
310 | def parse_params_for_bulk_issue_attributes(params) |
|
312 | def parse_params_for_bulk_issue_attributes(params) | |
311 | attributes = (params[:issue] || {}).reject {|k,v| v.blank?} |
|
313 | attributes = (params[:issue] || {}).reject {|k,v| v.blank?} | |
312 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} |
|
314 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} | |
313 | attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values] |
|
315 | attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values] | |
314 | attributes |
|
316 | attributes | |
315 | end |
|
317 | end | |
316 | end |
|
318 | end |
@@ -1,10 +1,10 | |||||
1 | <% changesets.each do |changeset| %> |
|
1 | <% changesets.each do |changeset| %> | |
2 | <div class="changeset <%= cycle('odd', 'even') %>"> |
|
2 | <div class="changeset <%= cycle('odd', 'even') %>"> | |
3 |
<p><%= link_to( |
|
3 | <p><%= link_to_revision(changeset, changeset.project, | |
4 | :controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %><br /> |
|
4 | :text => "#{l(:label_revision)} #{changeset.format_identifier}") %><br /> | |
5 | <span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> |
|
5 | <span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> | |
6 | <div class="changeset-changes"> |
|
6 | <div class="changeset-changes"> | |
7 | <%= textilizable(changeset, :comments) %> |
|
7 | <%= textilizable(changeset, :comments) %> | |
8 | </div> |
|
8 | </div> | |
9 | </div> |
|
9 | </div> | |
10 | <% end %> |
|
10 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now