From dbc8d3bfd67d50b248fcadf5f2ab34ae4e545514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 11 Oct 2021 19:07:32 +0200 Subject: [PATCH] refacto --- app/controllers/admin/import_csvs_controller.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/import_csvs_controller.rb b/app/controllers/admin/import_csvs_controller.rb index 9d3ebb1..bac0c29 100644 --- a/app/controllers/admin/import_csvs_controller.rb +++ b/app/controllers/admin/import_csvs_controller.rb @@ -94,19 +94,11 @@ class Admin::ImportCsvsController < ApplicationController end def temp_p_product - dev_mode = false - if dev_mode - @p_product_ref = PProductRef.last #DEV mode only + if params[:price_line_id] @price_line = PriceLine.find(params[:price_line_id]) - - @p_product_ref.ct_price_ht = @price_line.ct_u_price_ht #DEV ode onmy + p_product = PProduct.find_or_create_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--") + @p_product_ref = PProductRef.find_or_create_by(p_product: p_product, ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) @p_product_ref.p_product_ref_specs.build - else - if params[:price_line_id] - @price_line = PriceLine.find(params[:price_line_id]) - @p_product_ref = PProductRef.find_or_create_by(p_product: PProduct.find_by(name: "--> Selectioner un produit <--"), ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) - @p_product_ref.p_product_ref_specs.build - end end end end