Add CSV download for ordergroups

This commit is contained in:
Patrick Gansterer 2018-12-21 01:12:43 +01:00
parent 389f205a6b
commit 71fd6f2a24
4 changed files with 56 additions and 2 deletions

View file

@ -1,10 +1,14 @@
# encoding: utf-8
class Admin::OrdergroupsController < Admin::BaseController
inherit_resources
def index
@ordergroups = Ordergroup.undeleted.order('name ASC')
if request.format.csv?
send_data OrdergroupsCsv.new(@ordergroups).to_csv, filename: 'ordergroups.csv', type: 'text/csv'
end
# if somebody uses the search field:
unless params[:query].blank?
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%")