This commit is contained in:
Nicolas Bally 2020-03-08 12:44:07 +01:00
parent 492e15481a
commit 548982d228
5 changed files with 72 additions and 9 deletions

View File

@ -28,6 +28,10 @@ class MOdr < ApplicationRecord
has_many :m_odr_products, :dependent => :destroy
accepts_nested_attributes_for :m_odr_products, :allow_destroy => true
has_many :m_odr_product_cats, :dependent => :destroy
accepts_nested_attributes_for :m_odr_product_cats, :allow_destroy => true
has_many :m_odr_places, :dependent => :destroy
accepts_nested_attributes_for :m_odr_places, :allow_destroy => true
@ -37,6 +41,8 @@ class MOdr < ApplicationRecord
has_many :mail_types, :dependent => :destroy
accepts_nested_attributes_for :mail_types, :allow_destroy => true
has_many :m_odr_product_remises, :through => :m_odr_products

View File

@ -31,9 +31,24 @@ class MOdrRep < ApplicationRecord
validates :m_odr_product_id, :presence => true
validates :m_odr_place_id, :presence => true
validates :rgpd, :presence => true, :if => :rgpd_needed?
belongs_to :m_odr_tracker
def rgpd_needed?
if self.m_odr and self.m_odr.confirm_case_needed
true
else
false
end
end
def send_mail_type(slug, element = nil)
if self.m_odr and mail_type = self.m_odr.mail_types.where(:slug => slug).first and self.particulars.first and self.particulars.first.email?

View File

@ -34,7 +34,7 @@ class Particular < ApplicationRecord
def force_email_validation
if self.validate_email and !skip_email
if self.validate_email and (!self.skip_email or self.skip_email.to_s == "")
true
else
false

View File

@ -1,5 +1,16 @@
Rails.application.routes.draw do
namespace :admin do
resources :m_odr_product_cats do
member do
end
collection do
end
end
end
namespace :public do
resources :file_tunel_downloads do
member do

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_03_03_153308) do
ActiveRecord::Schema.define(version: 2020_03_07_104157) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name"
@ -321,7 +321,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.datetime "updated_at", precision: 6, null: false
end
create_table "file_tunel_downloads", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "file_tunel_downloads", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.bigint "file_tunel_id"
t.bigint "file_tunel_send_id"
t.string "name"
@ -338,7 +338,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.index ["file_tunel_send_id"], name: "index_file_tunel_downloads_on_file_tunel_send_id"
end
create_table "file_tunel_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "file_tunel_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.string "file"
t.string "token"
t.boolean "enabled", default: true
@ -348,9 +348,10 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.bigint "file_tunel_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["file_tunel_id"], name: "index_file_tunel_files_on_file_tunel_id"
end
create_table "file_tunel_sends", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "file_tunel_sends", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.bigint "file_tunel_id"
t.string "token"
t.string "email"
@ -361,9 +362,10 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.string "mj_token"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["file_tunel_id"], name: "index_file_tunel_sends_on_file_tunel_id"
end
create_table "file_tunels", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "file_tunels", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.string "name"
t.text "description"
t.string "slug"
@ -632,6 +634,14 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.index ["m_odr_id"], name: "index_m_odr_places_on_m_odr_id"
end
create_table "m_odr_product_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.bigint "m_odr_id"
t.string "name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["m_odr_id"], name: "index_m_odr_product_cats_on_m_odr_id"
end
create_table "m_odr_product_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.bigint "m_odr_product_id"
t.integer "qte"
@ -653,7 +663,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.index ["m_odr_id"], name: "index_m_odr_products_on_m_odr_id"
end
create_table "m_odr_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "m_odr_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.text "notes"
t.bigint "m_odr_id"
t.datetime "download_at"
@ -661,6 +671,8 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.string "state", default: "Généré"
t.boolean "confirmed", default: false
t.integer "admin_id"
t.integer "cc_nbr_virements"
t.integer "ac_nbr_virements"
t.string "cc_iban_from"
t.string "ac_iban_from"
t.string "cc_bic_from"
@ -749,8 +761,10 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.boolean "ac_file_admin_ok", default: false
t.boolean "cc_admin_ok_to_send", default: false
t.boolean "ac_admin_ok_to_send", default: false
t.bigint "m_odr_product_cat_id"
t.index ["m_odr_id"], name: "index_m_odr_reps_on_m_odr_id"
t.index ["m_odr_place_id"], name: "index_m_odr_reps_on_m_odr_place_id"
t.index ["m_odr_product_cat_id"], name: "index_m_odr_reps_on_m_odr_product_cat_id"
t.index ["m_odr_product_id"], name: "index_m_odr_reps_on_m_odr_product_id"
t.index ["m_odr_tracker_id"], name: "index_m_odr_reps_on_m_odr_tracker_id"
end
@ -764,7 +778,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.index ["m_odr_id"], name: "index_m_odr_trackers_on_m_odr_id"
end
create_table "m_odr_virements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "m_odr_virements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.bigint "m_odr_id"
t.bigint "m_odr_rep_id"
t.bigint "m_odr_rep_rib_id"
@ -846,6 +860,19 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.string "bank_name"
t.string "bank_ics"
t.string "bank_subject"
t.string "name_label"
t.string "firstname_label"
t.boolean "placeholder", default: false
t.boolean "email_process", default: true
t.boolean "tel_process", default: true
t.boolean "rib_needed", default: true
t.boolean "address_needed", default: true
t.boolean "confirm_case_needed", default: false
t.string "confirm_case_label", default: "0"
t.string "product_cat_label"
t.string "product_label"
t.string "qte_label"
t.string "place_label"
t.index ["p_customer_id"], name: "index_m_odrs_on_p_customer_id"
end
@ -865,7 +892,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
t.index ["mail_type_id"], name: "index_mail_contents_on_mail_type_id"
end
create_table "mail_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "mail_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.bigint "lang_site_id"
t.string "from_email"
t.string "to_email"
@ -2532,6 +2559,8 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
add_foreign_key "admin_preferences", "admins"
add_foreign_key "file_tunel_downloads", "file_tunel_sends"
add_foreign_key "file_tunel_downloads", "file_tunels"
add_foreign_key "file_tunel_files", "file_tunels"
add_foreign_key "file_tunel_sends", "file_tunels"
add_foreign_key "file_tunels", "admins"
add_foreign_key "file_tunels", "p_customers"
add_foreign_key "i_task_projects", "admins"
@ -2541,9 +2570,11 @@ ActiveRecord::Schema.define(version: 2020_03_03_153308) do
add_foreign_key "m_odr_file_types", "m_odrs"
add_foreign_key "m_odr_files", "m_odr_reps"
add_foreign_key "m_odr_places", "m_odrs"
add_foreign_key "m_odr_product_cats", "m_odrs"
add_foreign_key "m_odr_product_remises", "m_odr_products"
add_foreign_key "m_odr_remises", "m_odrs"
add_foreign_key "m_odr_rep_ribs", "admins"
add_foreign_key "m_odr_reps", "m_odr_product_cats"
add_foreign_key "m_odr_reps", "m_odr_trackers"
add_foreign_key "m_odr_trackers", "m_odrs"
add_foreign_key "m_odr_virements", "m_odr_rep_ribs"