diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 6c388cf..bdbdbcf 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -80,10 +80,15 @@ class PCustomer < ApplicationRecord self.m_odr_rep_ribs.create(:bic => self.imp_bic, :iban => self.imp_iban, :admin_ok => true) end + if self.imp_test == "oui" + self.test_user = true + end + if self.particular part = self.particular else part = Particular.new + part.owner = self end part.name = self.imp_name part.firstname = self.imp_firstname @@ -129,7 +134,9 @@ class PCustomer < ApplicationRecord end - #after_create :do_import + after_create do + do_import() if self.imp_email? + end after_update do #self.do_import if self.refresh_import diff --git a/app/views/admin/p_customers/_form.html.haml b/app/views/admin/p_customers/_form.html.haml index a24e94a..e001f90 100755 --- a/app/views/admin/p_customers/_form.html.haml +++ b/app/views/admin/p_customers/_form.html.haml @@ -20,18 +20,27 @@ .row.qi_cancel_margins - .col-sm-4 + .col-sm-2 = form.input :parent_id, :label => "Ambassadeur :", :include_blank => true, :collection => PCustomer.where(:ambassadeur => true).all, :as => :select, :member_label => :member_label - .col-sm-4 + .col-sm-2 %br - = form.input :enabled, :label => "Utilisateur actif ?", :as => :boolean, :input_html => {:id => ""} + = form.input :enabled, :label => "Utilisateur actif ?", :as => :boolean - .col-sm-4 + .col-sm-2 %br - = form.input :ambassadeur, :label => "Ambassadeur ?", :as => :boolean, :input_html => {:id => ""} - + = form.input :ambassadeur, :label => "Ambassadeur ?", :as => :boolean + + .col-sm-2 + %br + = form.input :sticker, :label => "Sticker envoyés ?" + + .col-sm-2 + %br + = form.input :test_user, :label => "Client test ?", :as => :boolean + + = form.input :tel, :label => "Tel :" = form.input :email, :label => "Email (login) :" @@ -66,7 +75,7 @@ = form.input :nbr_roulages, :label => "Nombre de roulage :", :include_blank => true, :collection => PCustomer::NBR_ROULAGES, :as => :select .col-sm-2 - = form.input :sticker, :label => "Sticker envoyés ?" + diff --git a/app/views/public/menu_items/index.html.haml b/app/views/public/menu_items/index.html.haml index 022cef8..271d626 100644 --- a/app/views/public/menu_items/index.html.haml +++ b/app/views/public/menu_items/index.html.haml @@ -39,7 +39,7 @@ .center_programme .block_num %span.chiffre - =PCustomer.where(:enabled => true).count + =PCustomer.where(:enabled => true, :test_user => false).count %span.label-chiffre Membres .block_num %span.chiffre diff --git a/db/migrate/20200625135439_add_test_user_to_p_customers.rb b/db/migrate/20200625135439_add_test_user_to_p_customers.rb new file mode 100644 index 0000000..cf7b565 --- /dev/null +++ b/db/migrate/20200625135439_add_test_user_to_p_customers.rb @@ -0,0 +1,7 @@ +class AddTestUserToPCustomers < ActiveRecord::Migration[6.0] + def change + add_column :p_customers, :test_user, :boolean, :default => false + + PCustomer.where(:imp_test => "oui").update_all :test_user => true + end +end diff --git a/db/schema.rb b/db/schema.rb index e80a635..2c38fb8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_06_24_140026) do +ActiveRecord::Schema.define(version: 2020_06_25_135439) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1722,6 +1722,7 @@ ActiveRecord::Schema.define(version: 2020_06_24_140026) do t.string "imp_demande_info" t.date "imp_creation" t.date "imp_modification" + t.boolean "test_user", default: false t.index ["market_discount_id"], name: "index_p_customers_on_market_discount_id" t.index ["p_customer_cat_id"], name: "index_p_customers_on_p_customer_cat_id" t.index ["particular_id"], name: "index_p_customers_on_particular_id"