Mercurial > hg > soundsoftware-site
comparison app/helpers/issues_helper.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # encoding: utf-8 | 1 # encoding: utf-8 |
2 # | 2 # |
3 # Redmine - project management software | 3 # Redmine - project management software |
4 # Copyright (C) 2006-2012 Jean-Philippe Lang | 4 # Copyright (C) 2006-2013 Jean-Philippe Lang |
5 # | 5 # |
6 # This program is free software; you can redistribute it and/or | 6 # This program is free software; you can redistribute it and/or |
7 # modify it under the terms of the GNU General Public License | 7 # modify it under the terms of the GNU General Public License |
8 # as published by the Free Software Foundation; either version 2 | 8 # as published by the Free Software Foundation; either version 2 |
9 # of the License, or (at your option) any later version. | 9 # of the License, or (at your option) any later version. |
182 message | 182 message |
183 end | 183 end |
184 | 184 |
185 def sidebar_queries | 185 def sidebar_queries |
186 unless @sidebar_queries | 186 unless @sidebar_queries |
187 @sidebar_queries = Query.visible.all( | 187 @sidebar_queries = IssueQuery.visible.all( |
188 :order => "#{Query.table_name}.name ASC", | 188 :order => "#{Query.table_name}.name ASC", |
189 # Project specific queries and global queries | 189 # Project specific queries and global queries |
190 :conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]) | 190 :conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]) |
191 ) | 191 ) |
192 end | 192 end |
345 end | 345 end |
346 end | 346 end |
347 | 347 |
348 # Find the name of an associated record stored in the field attribute | 348 # Find the name of an associated record stored in the field attribute |
349 def find_name_by_reflection(field, id) | 349 def find_name_by_reflection(field, id) |
350 unless id.present? | |
351 return nil | |
352 end | |
350 association = Issue.reflect_on_association(field.to_sym) | 353 association = Issue.reflect_on_association(field.to_sym) |
351 if association | 354 if association |
352 record = association.class_name.constantize.find_by_id(id) | 355 record = association.class_name.constantize.find_by_id(id) |
353 if record | 356 if record |
354 record.name.force_encoding('UTF-8') if record.name.respond_to?(:force_encoding) | 357 record.name.force_encoding('UTF-8') if record.name.respond_to?(:force_encoding) |
368 render_api_issue_children(child, api) | 371 render_api_issue_children(child, api) |
369 end | 372 end |
370 end | 373 end |
371 end | 374 end |
372 end | 375 end |
373 | |
374 def issues_to_csv(issues, project, query, options={}) | |
375 decimal_separator = l(:general_csv_decimal_separator) | |
376 encoding = l(:general_csv_encoding) | |
377 columns = (options[:columns] == 'all' ? query.available_inline_columns : query.inline_columns) | |
378 if options[:description] | |
379 if description = query.available_columns.detect {|q| q.name == :description} | |
380 columns << description | |
381 end | |
382 end | |
383 | |
384 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| | |
385 # csv header fields | |
386 csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } | |
387 | |
388 # csv lines | |
389 issues.each do |issue| | |
390 col_values = columns.collect do |column| | |
391 s = if column.is_a?(QueryCustomFieldColumn) | |
392 cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id} | |
393 show_value(cv) | |
394 else | |
395 value = column.value(issue) | |
396 if value.is_a?(Date) | |
397 format_date(value) | |
398 elsif value.is_a?(Time) | |
399 format_time(value) | |
400 elsif value.is_a?(Float) | |
401 ("%.2f" % value).gsub('.', decimal_separator) | |
402 else | |
403 value | |
404 end | |
405 end | |
406 s.to_s | |
407 end | |
408 csv << [ issue.id.to_s ] + col_values.collect {|c| Redmine::CodesetUtil.from_utf8(c.to_s, encoding) } | |
409 end | |
410 end | |
411 export | |
412 end | |
413 end | 376 end |