openSUSE/osem

View on GitHub
app/views/admin/tracks/_all_tracks.xlsx.axlsx

Summary

Maintainability
Test Coverage
# frozen_string_literal: true

wb.add_worksheet(name: 'all tracks') do |sheet|
  bold_style = wb.styles.add_style(b: true)
  wrap_text = wb.styles.add_style alignment: {wrap_text: true}
  row = ['Track ID',
         'Name',
         'Description',
         'Room',
         'Start Date',
         'End Date',
         'Submitter Name',
         'Included in Cfp',
         'State']
  sheet.add_row row, style: bold_style

  @tracks.each do |track|
    row = []
    row << track.id
    row << track.name.to_s
    row << track.description.to_s
    row << track.try(:room).try(:name)
    row << track.start_date.to_s
    row << track.end_date.to_s
    row << track.try(:submitter).try(:name)
    row << (track.cfp_active? ? 'Yes' : 'No')
    row << track.state
    sheet.add_row row , style: wrap_text
    sheet.column_widths 10,20,50,20,12,12,20,15,10
  end
end