@@ -1,442 +1,441 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class IssuesController < ApplicationController |
|
19 | 19 | menu_item :new_issue, :only => [:new, :create] |
|
20 | 20 | default_search_scope :issues |
|
21 | 21 | |
|
22 | 22 | before_filter :find_issue, :only => [:show, :edit, :update] |
|
23 | 23 | before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] |
|
24 | 24 | before_filter :find_project, :only => [:new, :create] |
|
25 | 25 | before_filter :authorize, :except => [:index] |
|
26 | 26 | before_filter :find_optional_project, :only => [:index] |
|
27 | 27 | before_filter :check_for_default_issue_status, :only => [:new, :create] |
|
28 | 28 | before_filter :build_new_issue_from_params, :only => [:new, :create] |
|
29 | 29 | accept_rss_auth :index, :show |
|
30 | 30 | accept_api_auth :index, :show, :create, :update, :destroy |
|
31 | 31 | |
|
32 | 32 | rescue_from Query::StatementInvalid, :with => :query_statement_invalid |
|
33 | 33 | |
|
34 | 34 | helper :journals |
|
35 | 35 | helper :projects |
|
36 | 36 | include ProjectsHelper |
|
37 | 37 | helper :custom_fields |
|
38 | 38 | include CustomFieldsHelper |
|
39 | 39 | helper :issue_relations |
|
40 | 40 | include IssueRelationsHelper |
|
41 | 41 | helper :watchers |
|
42 | 42 | include WatchersHelper |
|
43 | 43 | helper :attachments |
|
44 | 44 | include AttachmentsHelper |
|
45 | 45 | helper :queries |
|
46 | 46 | include QueriesHelper |
|
47 | 47 | helper :repositories |
|
48 | 48 | include RepositoriesHelper |
|
49 | 49 | helper :sort |
|
50 | 50 | include SortHelper |
|
51 | 51 | include IssuesHelper |
|
52 | 52 | helper :timelog |
|
53 | helper :gantt | |
|
54 | 53 | include Redmine::Export::PDF |
|
55 | 54 | |
|
56 | 55 | def index |
|
57 | 56 | retrieve_query |
|
58 | 57 | sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) |
|
59 | 58 | sort_update(@query.sortable_columns) |
|
60 | 59 | |
|
61 | 60 | if @query.valid? |
|
62 | 61 | case params[:format] |
|
63 | 62 | when 'csv', 'pdf' |
|
64 | 63 | @limit = Setting.issues_export_limit.to_i |
|
65 | 64 | when 'atom' |
|
66 | 65 | @limit = Setting.feeds_limit.to_i |
|
67 | 66 | when 'xml', 'json' |
|
68 | 67 | @offset, @limit = api_offset_and_limit |
|
69 | 68 | else |
|
70 | 69 | @limit = per_page_option |
|
71 | 70 | end |
|
72 | 71 | |
|
73 | 72 | @issue_count = @query.issue_count |
|
74 | 73 | @issue_pages = Paginator.new self, @issue_count, @limit, params['page'] |
|
75 | 74 | @offset ||= @issue_pages.current.offset |
|
76 | 75 | @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], |
|
77 | 76 | :order => sort_clause, |
|
78 | 77 | :offset => @offset, |
|
79 | 78 | :limit => @limit) |
|
80 | 79 | @issue_count_by_group = @query.issue_count_by_group |
|
81 | 80 | |
|
82 | 81 | respond_to do |format| |
|
83 | 82 | format.html { render :template => 'issues/index', :layout => !request.xhr? } |
|
84 | 83 | format.api { |
|
85 | 84 | Issue.load_relations(@issues) if include_in_api_response?('relations') |
|
86 | 85 | } |
|
87 | 86 | format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } |
|
88 | 87 | format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') } |
|
89 | 88 | format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') } |
|
90 | 89 | end |
|
91 | 90 | else |
|
92 | 91 | respond_to do |format| |
|
93 | 92 | format.html { render(:template => 'issues/index', :layout => !request.xhr?) } |
|
94 | 93 | format.any(:atom, :csv, :pdf) { render(:nothing => true) } |
|
95 | 94 | format.api { render_validation_errors(@query) } |
|
96 | 95 | end |
|
97 | 96 | end |
|
98 | 97 | rescue ActiveRecord::RecordNotFound |
|
99 | 98 | render_404 |
|
100 | 99 | end |
|
101 | 100 | |
|
102 | 101 | def show |
|
103 | 102 | @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") |
|
104 | 103 | @journals.each_with_index {|j,i| j.indice = i+1} |
|
105 | 104 | @journals.reverse! if User.current.wants_comments_in_reverse_order? |
|
106 | 105 | |
|
107 | 106 | @changesets = @issue.changesets.visible.all |
|
108 | 107 | @changesets.reverse! if User.current.wants_comments_in_reverse_order? |
|
109 | 108 | |
|
110 | 109 | @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
|
111 | 110 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
|
112 | 111 | @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
|
113 | 112 | @priorities = IssuePriority.active |
|
114 | 113 | @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
|
115 | 114 | respond_to do |format| |
|
116 | 115 | format.html { |
|
117 | 116 | retrieve_previous_and_next_issue_ids |
|
118 | 117 | render :template => 'issues/show' |
|
119 | 118 | } |
|
120 | 119 | format.api |
|
121 | 120 | format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } |
|
122 | 121 | format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") } |
|
123 | 122 | end |
|
124 | 123 | end |
|
125 | 124 | |
|
126 | 125 | # Add a new issue |
|
127 | 126 | # The new issue will be created from an existing one if copy_from parameter is given |
|
128 | 127 | def new |
|
129 | 128 | respond_to do |format| |
|
130 | 129 | format.html { render :action => 'new', :layout => !request.xhr? } |
|
131 | 130 | format.js { |
|
132 | 131 | render(:update) { |page| |
|
133 | 132 | if params[:project_change] |
|
134 | 133 | page.replace_html 'all_attributes', :partial => 'form' |
|
135 | 134 | else |
|
136 | 135 | page.replace_html 'attributes', :partial => 'attributes' |
|
137 | 136 | end |
|
138 | 137 | m = User.current.allowed_to?(:log_time, @issue.project) ? 'show' : 'hide' |
|
139 | 138 | page << "if ($('log_time')) {Element.#{m}('log_time');}" |
|
140 | 139 | } |
|
141 | 140 | } |
|
142 | 141 | end |
|
143 | 142 | end |
|
144 | 143 | |
|
145 | 144 | def create |
|
146 | 145 | call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) |
|
147 | 146 | @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) |
|
148 | 147 | if @issue.save |
|
149 | 148 | call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) |
|
150 | 149 | respond_to do |format| |
|
151 | 150 | format.html { |
|
152 | 151 | render_attachment_warning_if_needed(@issue) |
|
153 | 152 | flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue))) |
|
154 | 153 | 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?} } : |
|
155 | 154 | { :action => 'show', :id => @issue }) |
|
156 | 155 | } |
|
157 | 156 | format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } |
|
158 | 157 | end |
|
159 | 158 | return |
|
160 | 159 | else |
|
161 | 160 | respond_to do |format| |
|
162 | 161 | format.html { render :action => 'new' } |
|
163 | 162 | format.api { render_validation_errors(@issue) } |
|
164 | 163 | end |
|
165 | 164 | end |
|
166 | 165 | end |
|
167 | 166 | |
|
168 | 167 | def edit |
|
169 | 168 | return unless update_issue_from_params |
|
170 | 169 | |
|
171 | 170 | respond_to do |format| |
|
172 | 171 | format.html { } |
|
173 | 172 | format.xml { } |
|
174 | 173 | end |
|
175 | 174 | end |
|
176 | 175 | |
|
177 | 176 | def update |
|
178 | 177 | return unless update_issue_from_params |
|
179 | 178 | @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) |
|
180 | 179 | saved = false |
|
181 | 180 | begin |
|
182 | 181 | saved = @issue.save_issue_with_child_records(params, @time_entry) |
|
183 | 182 | rescue ActiveRecord::StaleObjectError |
|
184 | 183 | @conflict = true |
|
185 | 184 | if params[:last_journal_id] |
|
186 | 185 | if params[:last_journal_id].present? |
|
187 | 186 | last_journal_id = params[:last_journal_id].to_i |
|
188 | 187 | @conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id]) |
|
189 | 188 | else |
|
190 | 189 | @conflict_journals = @issue.journals.all |
|
191 | 190 | end |
|
192 | 191 | end |
|
193 | 192 | end |
|
194 | 193 | |
|
195 | 194 | if saved |
|
196 | 195 | render_attachment_warning_if_needed(@issue) |
|
197 | 196 | flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? |
|
198 | 197 | |
|
199 | 198 | respond_to do |format| |
|
200 | 199 | format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } |
|
201 | 200 | format.api { head :ok } |
|
202 | 201 | end |
|
203 | 202 | else |
|
204 | 203 | respond_to do |format| |
|
205 | 204 | format.html { render :action => 'edit' } |
|
206 | 205 | format.api { render_validation_errors(@issue) } |
|
207 | 206 | end |
|
208 | 207 | end |
|
209 | 208 | end |
|
210 | 209 | |
|
211 | 210 | # Bulk edit/copy a set of issues |
|
212 | 211 | def bulk_edit |
|
213 | 212 | @issues.sort! |
|
214 | 213 | @copy = params[:copy].present? |
|
215 | 214 | @notes = params[:notes] |
|
216 | 215 | |
|
217 | 216 | if User.current.allowed_to?(:move_issues, @projects) |
|
218 | 217 | @allowed_projects = Issue.allowed_target_projects_on_move |
|
219 | 218 | if params[:issue] |
|
220 | 219 | @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} |
|
221 | 220 | if @target_project |
|
222 | 221 | target_projects = [@target_project] |
|
223 | 222 | end |
|
224 | 223 | end |
|
225 | 224 | end |
|
226 | 225 | target_projects ||= @projects |
|
227 | 226 | |
|
228 | 227 | if @copy |
|
229 | 228 | @available_statuses = [IssueStatus.default] |
|
230 | 229 | else |
|
231 | 230 | @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) |
|
232 | 231 | end |
|
233 | 232 | @custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&) |
|
234 | 233 | @assignables = target_projects.map(&:assignable_users).reduce(:&) |
|
235 | 234 | @trackers = target_projects.map(&:trackers).reduce(:&) |
|
236 | 235 | @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) |
|
237 | 236 | @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) |
|
238 | 237 | if @copy |
|
239 | 238 | @attachments_present = @issues.detect {|i| i.attachments.any?}.present? |
|
240 | 239 | end |
|
241 | 240 | |
|
242 | 241 | @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) |
|
243 | 242 | render :layout => false if request.xhr? |
|
244 | 243 | end |
|
245 | 244 | |
|
246 | 245 | def bulk_update |
|
247 | 246 | @issues.sort! |
|
248 | 247 | @copy = params[:copy].present? |
|
249 | 248 | attributes = parse_params_for_bulk_issue_attributes(params) |
|
250 | 249 | |
|
251 | 250 | unsaved_issue_ids = [] |
|
252 | 251 | moved_issues = [] |
|
253 | 252 | @issues.each do |issue| |
|
254 | 253 | issue.reload |
|
255 | 254 | if @copy |
|
256 | 255 | issue = issue.copy({}, :attachments => params[:copy_attachments].present?) |
|
257 | 256 | end |
|
258 | 257 | journal = issue.init_journal(User.current, params[:notes]) |
|
259 | 258 | issue.safe_attributes = attributes |
|
260 | 259 | call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) |
|
261 | 260 | if issue.save |
|
262 | 261 | moved_issues << issue |
|
263 | 262 | else |
|
264 | 263 | # Keep unsaved issue ids to display them in flash error |
|
265 | 264 | unsaved_issue_ids << issue.id |
|
266 | 265 | end |
|
267 | 266 | end |
|
268 | 267 | set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) |
|
269 | 268 | |
|
270 | 269 | if params[:follow] |
|
271 | 270 | if @issues.size == 1 && moved_issues.size == 1 |
|
272 | 271 | redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first |
|
273 | 272 | elsif moved_issues.map(&:project).uniq.size == 1 |
|
274 | 273 | redirect_to :controller => 'issues', :action => 'index', :project_id => moved_issues.map(&:project).first |
|
275 | 274 | end |
|
276 | 275 | else |
|
277 | 276 | redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) |
|
278 | 277 | end |
|
279 | 278 | end |
|
280 | 279 | |
|
281 | 280 | def destroy |
|
282 | 281 | @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f |
|
283 | 282 | if @hours > 0 |
|
284 | 283 | case params[:todo] |
|
285 | 284 | when 'destroy' |
|
286 | 285 | # nothing to do |
|
287 | 286 | when 'nullify' |
|
288 | 287 | TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) |
|
289 | 288 | when 'reassign' |
|
290 | 289 | reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) |
|
291 | 290 | if reassign_to.nil? |
|
292 | 291 | flash.now[:error] = l(:error_issue_not_found_in_project) |
|
293 | 292 | return |
|
294 | 293 | else |
|
295 | 294 | TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) |
|
296 | 295 | end |
|
297 | 296 | else |
|
298 | 297 | # display the destroy form if it's a user request |
|
299 | 298 | return unless api_request? |
|
300 | 299 | end |
|
301 | 300 | end |
|
302 | 301 | @issues.each do |issue| |
|
303 | 302 | begin |
|
304 | 303 | issue.reload.destroy |
|
305 | 304 | rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists |
|
306 | 305 | # nothing to do, issue was already deleted (eg. by a parent) |
|
307 | 306 | end |
|
308 | 307 | end |
|
309 | 308 | respond_to do |format| |
|
310 | 309 | format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } |
|
311 | 310 | format.api { head :ok } |
|
312 | 311 | end |
|
313 | 312 | end |
|
314 | 313 | |
|
315 | 314 | private |
|
316 | 315 | def find_issue |
|
317 | 316 | # Issue.visible.find(...) can not be used to redirect user to the login form |
|
318 | 317 | # if the issue actually exists but requires authentication |
|
319 | 318 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) |
|
320 | 319 | unless @issue.visible? |
|
321 | 320 | deny_access |
|
322 | 321 | return |
|
323 | 322 | end |
|
324 | 323 | @project = @issue.project |
|
325 | 324 | rescue ActiveRecord::RecordNotFound |
|
326 | 325 | render_404 |
|
327 | 326 | end |
|
328 | 327 | |
|
329 | 328 | def find_project |
|
330 | 329 | project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id]) |
|
331 | 330 | @project = Project.find(project_id) |
|
332 | 331 | rescue ActiveRecord::RecordNotFound |
|
333 | 332 | render_404 |
|
334 | 333 | end |
|
335 | 334 | |
|
336 | 335 | def retrieve_previous_and_next_issue_ids |
|
337 | 336 | retrieve_query_from_session |
|
338 | 337 | if @query |
|
339 | 338 | sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) |
|
340 | 339 | sort_update(@query.sortable_columns, 'issues_index_sort') |
|
341 | 340 | limit = 500 |
|
342 | 341 | issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) |
|
343 | 342 | if (idx = issue_ids.index(@issue.id)) && idx < limit |
|
344 | 343 | if issue_ids.size < 500 |
|
345 | 344 | @issue_position = idx + 1 |
|
346 | 345 | @issue_count = issue_ids.size |
|
347 | 346 | end |
|
348 | 347 | @prev_issue_id = issue_ids[idx - 1] if idx > 0 |
|
349 | 348 | @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1) |
|
350 | 349 | end |
|
351 | 350 | end |
|
352 | 351 | end |
|
353 | 352 | |
|
354 | 353 | # Used by #edit and #update to set some common instance variables |
|
355 | 354 | # from the params |
|
356 | 355 | # TODO: Refactor, not everything in here is needed by #edit |
|
357 | 356 | def update_issue_from_params |
|
358 | 357 | @edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
|
359 | 358 | @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
|
360 | 359 | @time_entry.attributes = params[:time_entry] |
|
361 | 360 | |
|
362 | 361 | @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) |
|
363 | 362 | @issue.init_journal(User.current, @notes) |
|
364 | 363 | |
|
365 | 364 | issue_attributes = params[:issue] |
|
366 | 365 | if issue_attributes && params[:conflict_resolution] |
|
367 | 366 | case params[:conflict_resolution] |
|
368 | 367 | when 'overwrite' |
|
369 | 368 | issue_attributes = issue_attributes.dup |
|
370 | 369 | issue_attributes.delete(:lock_version) |
|
371 | 370 | when 'add_notes' |
|
372 | 371 | issue_attributes = {} |
|
373 | 372 | when 'cancel' |
|
374 | 373 | redirect_to issue_path(@issue) |
|
375 | 374 | return false |
|
376 | 375 | end |
|
377 | 376 | end |
|
378 | 377 | @issue.safe_attributes = issue_attributes |
|
379 | 378 | @priorities = IssuePriority.active |
|
380 | 379 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
|
381 | 380 | true |
|
382 | 381 | end |
|
383 | 382 | |
|
384 | 383 | # TODO: Refactor, lots of extra code in here |
|
385 | 384 | # TODO: Changing tracker on an existing issue should not trigger this |
|
386 | 385 | def build_new_issue_from_params |
|
387 | 386 | if params[:id].blank? |
|
388 | 387 | @issue = Issue.new |
|
389 | 388 | if params[:copy_from] |
|
390 | 389 | begin |
|
391 | 390 | @copy_from = Issue.visible.find(params[:copy_from]) |
|
392 | 391 | @copy_attachments = params[:copy_attachments].present? || request.get? |
|
393 | 392 | @issue.copy_from(@copy_from, :attachments => @copy_attachments) |
|
394 | 393 | rescue ActiveRecord::RecordNotFound |
|
395 | 394 | render_404 |
|
396 | 395 | return |
|
397 | 396 | end |
|
398 | 397 | end |
|
399 | 398 | @issue.project = @project |
|
400 | 399 | else |
|
401 | 400 | @issue = @project.issues.visible.find(params[:id]) |
|
402 | 401 | end |
|
403 | 402 | |
|
404 | 403 | @issue.project = @project |
|
405 | 404 | @issue.author = User.current |
|
406 | 405 | # Tracker must be set before custom field values |
|
407 | 406 | @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |
|
408 | 407 | if @issue.tracker.nil? |
|
409 | 408 | render_error l(:error_no_tracker_in_project) |
|
410 | 409 | return false |
|
411 | 410 | end |
|
412 | 411 | @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date? |
|
413 | 412 | @issue.safe_attributes = params[:issue] |
|
414 | 413 | |
|
415 | 414 | @priorities = IssuePriority.active |
|
416 | 415 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) |
|
417 | 416 | @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq |
|
418 | 417 | end |
|
419 | 418 | |
|
420 | 419 | def check_for_default_issue_status |
|
421 | 420 | if IssueStatus.default.nil? |
|
422 | 421 | render_error l(:error_no_default_issue_status) |
|
423 | 422 | return false |
|
424 | 423 | end |
|
425 | 424 | end |
|
426 | 425 | |
|
427 | 426 | def parse_params_for_bulk_issue_attributes(params) |
|
428 | 427 | attributes = (params[:issue] || {}).reject {|k,v| v.blank?} |
|
429 | 428 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} |
|
430 | 429 | if custom = attributes[:custom_field_values] |
|
431 | 430 | custom.reject! {|k,v| v.blank?} |
|
432 | 431 | custom.keys.each do |k| |
|
433 | 432 | if custom[k].is_a?(Array) |
|
434 | 433 | custom[k] << '' if custom[k].delete('__none__') |
|
435 | 434 | else |
|
436 | 435 | custom[k] = '' if custom[k] == '__none__' |
|
437 | 436 | end |
|
438 | 437 | end |
|
439 | 438 | end |
|
440 | 439 | attributes |
|
441 | 440 | end |
|
442 | 441 | end |
General Comments 0
You need to be logged in to leave comments.
Login now