add rute and controller method to orders controller

This commit is contained in:
viehlieb 2023-02-14 16:54:03 +01:00
parent e540cb1e59
commit 259d919175
2 changed files with 15 additions and 1 deletions

View file

@ -49,7 +49,7 @@ class OrdersController < ApplicationController
send_order_pdf @order, params[:document]
end
format.csv do
send_data OrderCsv.new(@order).to_csv, filename: @order.name + '.csv', type: 'text/csv'
send_data OrderCsv.new(@order, options= {custom_csv: params[:custom_csv]}).to_csv, filename: @order.name + '.csv', type: 'text/csv'
end
format.text do
send_data OrderTxt.new(@order).to_txt, filename: @order.name + '.txt', type: 'text/plain'
@ -57,6 +57,19 @@ class OrdersController < ApplicationController
end
end
def custom_csv
@order = Order.find(params[:id])
@view = (params[:view] || 'default').gsub(/[^-_a-zA-Z0-9]/, '')
@partial = case @view
when 'default' then 'articles'
when 'groups' then 'shared/articles_by/groups'
when 'articles' then 'shared/articles_by/articles'
else 'articles'
end
render :layout => false
end
# Page to create a new order.
def new
if params[:order_id]

View file

@ -47,6 +47,7 @@ Rails.application.routes.draw do
get :receive
post :receive
get :custom_csv
get :receive_on_order_article_create
get :receive_on_order_article_update
end