diff --git a/app/models/import_csv.rb b/app/models/import_csv.rb index 7414d1b..9e018a7 100644 --- a/app/models/import_csv.rb +++ b/app/models/import_csv.rb @@ -58,9 +58,11 @@ class ImportCsv < ApplicationRecord def charge - self.import_csv_elements.each do |e| - e.element.destroy if e.element - e.destroy + if false + self.import_csv_elements.each do |e| + e.element.destroy if e.element + e.destroy + end end csv_text = File.read(self.file.path, :encoding => 'UTF-8') diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index f7b3856..e941b45 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -73,12 +73,18 @@ class PCustomer < ApplicationRecord validates :past_id, :uniqueness => true, :if => :imported + attr_accessor :refresh_import + def do_import if self.imp_iban? and self.imp_bic? self.m_odr_rep_ribs.create(:bic => self.imp_bic, :iban => self.imp_iban, :admin_ok => true) end - part = Particular.new + if self.particular + part = self.particular + else + part = Particular.new + end part.name = self.imp_name part.firstname = self.imp_firstname part.address_2 = self.imp_address @@ -125,6 +131,10 @@ class PCustomer < ApplicationRecord after_create :do_import + after_save do + self.do_import if self.refresh_import + end + acts_as_csv_import :fields =>[:imported, :email, :password, :past_id,:imp_cp,:imp_country,:imp_ref,:imp_email,:imp_firstname,:imp_name,:imp_fonction,:imp_organisme,:imp_address,:imp_cp2,:imp_city,:imp_tel,:imp_portable,:imp_lien,:imp_comment,:imp_iban,:imp_bic,:imp_circuit_1,:imp_circuit_2,:imp_circuit_3,:imp_partenaire,:imp_ecran,:imp_blocage,:imp_valid,:imp_user_valid,:imp_offre,:imp_info,:imp_cgu,:imp_test,:imp_stickers,:imp_npai,:npai,:imp_relance_adresse,:imp_demande_info,:imp_creation,:imp_modification] attr_accessor :actual_password, :valid_last_password, :valid_public, :generate_mdp, :valid_pswd_confirmation, :require_cgv diff --git a/app/views/public/m_odr_rep_ribs/_form.html.haml b/app/views/public/m_odr_rep_ribs/_form.html.haml index 0811548..62dc8ca 100644 --- a/app/views/public/m_odr_rep_ribs/_form.html.haml +++ b/app/views/public/m_odr_rep_ribs/_form.html.haml @@ -12,5 +12,5 @@ = f.input :bic, :label => "Bic :" - .actions=f.submit "sauvegarder" #, :class => "btn btn-primary" + %center=f.submit "sauvegarder" #, :class => "btn btn-primary" \ No newline at end of file diff --git a/lib/acts_as_csv_import/hook.rb b/lib/acts_as_csv_import/hook.rb index a11f798..61cad71 100644 --- a/lib/acts_as_csv_import/hook.rb +++ b/lib/acts_as_csv_import/hook.rb @@ -21,7 +21,7 @@ module ActsAsCsvImport::Hook def self.default_import_csv(list, import_csv) list.each do |row| - if false + if row["past_id"] #false if n = self.where(:past_id => row["past_id"]).first else n = self.new