imports val de vienne
This commit is contained in:
parent
6649167bee
commit
0438ecf52e
@ -6,6 +6,8 @@ class ImportCsv < ApplicationRecord
|
||||
|
||||
has_many :import_csv_elements
|
||||
|
||||
has_many :elements, :through => :import_csv_elements
|
||||
|
||||
acts_as_tree
|
||||
|
||||
validates :file, :presence => true
|
||||
@ -40,11 +42,11 @@ class ImportCsv < ApplicationRecord
|
||||
self.import_csv_headers << ImportCsvHeader.new(:name => header)
|
||||
|
||||
end
|
||||
|
||||
self.table_name.classify.constantize.import_csv_fields.each do |h|
|
||||
|
||||
self.table_source.classify.constantize.import_csv_fields.each do |h|
|
||||
if self.parent and c = self.parent.import_csv_champs.where(:champ => h.to_s).first
|
||||
self.import_csv_champs.new(:champ => h.to_s, :header => c.header)
|
||||
else
|
||||
self.import_csv_champs.new(:champ => h.to_s, :header => c.header, :value => c.value)
|
||||
elsif !self.parent
|
||||
self.import_csv_champs.new(:champ => h.to_s)
|
||||
end
|
||||
|
||||
@ -55,6 +57,15 @@ class ImportCsv < ApplicationRecord
|
||||
|
||||
|
||||
end
|
||||
|
||||
def table_source
|
||||
if self.table_name == "val_de_vienne"
|
||||
name = "p_customer"
|
||||
else
|
||||
name = self.table_name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def charge
|
||||
|
||||
@ -87,7 +98,7 @@ class ImportCsv < ApplicationRecord
|
||||
end
|
||||
|
||||
def load
|
||||
self.table_name.classify.constantize.import_csv(self.charge, self)
|
||||
self.table_source.classify.constantize.import_csv(self.charge, self)
|
||||
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ class PCustomer < ApplicationRecord
|
||||
validates :cgv, :presence => true, :if => :require_cgv
|
||||
#validates :rgpd, :presence => true, :if => :require_cgv
|
||||
|
||||
validates :past_id, :uniqueness => true, :if => :imported
|
||||
#validates :past_id, :uniqueness => true, :if => :imported
|
||||
|
||||
acts_as_caching :fields => [:show_name, :particular_name, :particular_firstname]
|
||||
|
||||
@ -127,15 +127,15 @@ class PCustomer < ApplicationRecord
|
||||
self.sticker = true
|
||||
end
|
||||
|
||||
if circuit = Circuit.where(:past_id => self.imp_circuit_1).first
|
||||
if self.imp_circuit_1? and circuit = Circuit.where(:past_id => self.imp_circuit_1).first
|
||||
self.circuit_1_id = circuit.id
|
||||
end
|
||||
|
||||
if circuit = Circuit.where(:past_id => self.imp_circuit_2).first
|
||||
if self.imp_circuit_2? and circuit = Circuit.where(:past_id => self.imp_circuit_2).first
|
||||
self.circuit_2_id = circuit.id
|
||||
end
|
||||
|
||||
if circuit = Circuit.where(:past_id => self.imp_circuit_3).first
|
||||
if self.imp_circuit_3? and circuit = Circuit.where(:past_id => self.imp_circuit_3).first
|
||||
self.circuit_3_id = circuit.id
|
||||
end
|
||||
|
||||
@ -160,7 +160,12 @@ class PCustomer < ApplicationRecord
|
||||
self.do_import if self.refresh_import == "true"
|
||||
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, :refresh_import]
|
||||
|
||||
before_validation do
|
||||
self.generate_mdp = true if !self.id and self.import_name == "val"
|
||||
end
|
||||
|
||||
acts_as_csv_import :fields =>[:generate_mdp, :imported,:import_name,:unlimited, :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, :refresh_import]
|
||||
|
||||
attr_accessor :actual_password, :valid_last_password, :valid_public, :generate_mdp, :valid_pswd_confirmation, :require_cgv
|
||||
|
||||
@ -202,7 +207,13 @@ class PCustomer < ApplicationRecord
|
||||
|
||||
|
||||
before_validation do
|
||||
|
||||
if !self.id and self.import_name = "val"
|
||||
if p = PCustomer.where(:email => self.email).first
|
||||
p.unlimited = true
|
||||
p.import_name = "val"
|
||||
p.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self.valid_last_password and !PCustomer.find(self.id).authenticate(self.actual_password)
|
||||
@ -239,9 +250,12 @@ class PCustomer < ApplicationRecord
|
||||
self.generate_mdp = false
|
||||
if self.save
|
||||
#GeneralMailer.send_qi_mail("fr", "generation_mdp", self.email, {"mdp" => ps}).deliver
|
||||
|
||||
mail_hist = MailHist.generate_mail(:fr, MailType.find_by_slug("generation_mdp"), self.email, {:arguments => {:mdp => ps, :civilite => self.particular.civilite, :nom => self.particular.name, :prenom => self.particular.firstname }, :p_customer => self, :element => self})
|
||||
|
||||
if self.import_name.to_s == "val"
|
||||
mail_hist = MailHist.generate_mail(:fr, MailType.find_by_slug("import_val_de_vienne"), self.email, {:arguments => {:mdp => ps, :civilite => self.particular.civilite, :nom => self.particular.name, :prenom => self.particular.firstname }, :p_customer => self, :element => self})
|
||||
else
|
||||
|
||||
mail_hist = MailHist.generate_mail(:fr, MailType.find_by_slug("generation_mdp"), self.email, {:arguments => {:mdp => ps, :civilite => self.particular.civilite, :nom => self.particular.name, :prenom => self.particular.firstname }, :p_customer => self, :element => self})
|
||||
end
|
||||
else
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
%tr.m_odr_product_remise_form.field
|
||||
%td{:style => "width:200px;"}= form.input :champ, :label => false, :as => :select, :collection => @import_csv.table_name.classify.constantize.import_csv_fields.map{|a| a.to_s}
|
||||
%td{:style => "width:200px;"}= form.input :champ, :label => false, :as => :select, :collection => @import_csv.table_source.classify.constantize.import_csv_fields.map{|a| a.to_s}
|
||||
|
||||
|
||||
-if !form.object.header? and @import_csv.import_csv_headers.all.map{|a| a.name}.include?(form.object.champ)
|
||||
|
@ -6,12 +6,12 @@
|
||||
= f.input :name, :label => "Nom de l'import :"
|
||||
= f.input :file, :label => "file :"
|
||||
|
||||
= f.input :table_name, :label => "Table :" , :as => :select, :collection => ["p_customers", "circuits", "organisateurs", "m_odr_product_sizes", "m_odr_places", "circuit_regions", "m_events", "departement_frances"]
|
||||
= f.input :table_name, :label => "Table :" , :as => :select, :collection => ["p_customers", "circuits", "organisateurs", "m_odr_product_sizes", "m_odr_places", "circuit_regions", "m_events", "departement_frances", "val_de_vienne"]
|
||||
|
||||
-if f.object.id
|
||||
%table.import_csv_champs_form
|
||||
-if f.object.import_csv_champs.count == 0
|
||||
-@import_csv.table_name.classify.constantize.import_csv_fields.each do |h|
|
||||
-@import_csv.table_source.classify.constantize.import_csv_fields.each do |h|
|
||||
-f.object.import_csv_champs.new(:champ => h.to_s)
|
||||
|
||||
=f.semantic_fields_for :import_csv_champs do |form|
|
||||
|
@ -7,4 +7,8 @@
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @import_csv
|
||||
=debug @import_csv
|
||||
|
||||
%table
|
||||
-@import_csv.import_csv_elements.all.each do |el|
|
||||
=render el.element if el.element
|
@ -22,7 +22,7 @@
|
||||
|
||||
.col-sm-2
|
||||
|
||||
= form.input :parent_id, :label => "Si un ambassadeur vous a parlé de nous, sélectionnez son nom dans la liste :", :include_blank => true, :collection => PCustomer.where(:ambassadeur => true).all, :as => :select, :member_label => :member_label
|
||||
= form.input :parent_id, :label => "Ambassadeur :", :include_blank => true, :collection => PCustomer.where(:ambassadeur => true).all, :as => :select, :member_label => :member_label
|
||||
|
||||
.col-sm-2
|
||||
%br
|
||||
@ -39,7 +39,18 @@
|
||||
.col-sm-2
|
||||
%br
|
||||
= form.input :test_user, :label => "Client test ?", :as => :boolean
|
||||
|
||||
|
||||
.row.qi_cancel_margins
|
||||
.col-sm-4
|
||||
%br
|
||||
= form.input :unlimited, :label => "Nbr de primes déplafonné ?", :as => :boolean
|
||||
|
||||
.col-sm-4
|
||||
= form.object.import_name
|
||||
|
||||
.col-sm-4
|
||||
=l form.object.import_date if form.object.import_date
|
||||
|
||||
|
||||
|
||||
=# form.input :tel, :label => "Tel :"
|
||||
|
@ -6,7 +6,7 @@
|
||||
=f.hidden_field :valid_public
|
||||
|
||||
-if PCustomer.where(:ambassadeur => true).count > 0
|
||||
=f.input :parent_code, :label => "Code ambassadeur", :collection => PCustomer.where(:ambassadeur => true).map{|a| ["#{a.mlm_token} - #{a.show_name}", a.mlm_token]}
|
||||
=f.input :parent_code, :label => "Si un ambassadeur vous a parlé de nous, sélectionnez son nom dans la liste :", :collection => PCustomer.where(:ambassadeur => true).map{|a| ["#{a.mlm_token} - #{a.show_name}", a.mlm_token]}
|
||||
|
||||
=f.input :email, :label => "Email"
|
||||
=f.input :password, :label => "Mot de passe", :as => :password
|
||||
|
@ -0,0 +1,7 @@
|
||||
class AddUnlimitedToPCustomers < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :p_customers, :unlimited, :boolean, :default => false
|
||||
add_column :p_customers, :import_name, :string
|
||||
add_column :p_customers, :import_date, :datetime
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user