Add column to customers table to register last time enterprise terms and

conditions were accepted so customer doesnt have to accept terms on all
checkouts but only when the enterprise updates the terms file
This commit is contained in:
Luis Ramos
2020-09-07 14:58:23 +01:00
parent 3c9c5862d1
commit 4d64bf6ece
3 changed files with 14 additions and 6 deletions

View File

@@ -1,5 +1,7 @@
- terms_and_conditions_activated = current_order.distributor.terms_and_conditions.file?
- customer_terms_and_conditions_accepted_at = spree_current_user.customer_of(current_order.distributor).andand.terms_and_conditions_accepted_at
- terms_and_conditions_already_accepted = customer_terms_and_conditions_accepted_at.present? && (customer_terms_and_conditions_accepted_at > current_order.distributor.terms_and_conditions_updated_at)
- if terms_and_conditions_activated
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_activated=#{terms_and_conditions_activated}" } }
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_activated=#{terms_and_conditions_activated}; terms_and_conditions_accepted=#{terms_and_conditions_already_accepted}" } }
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank'))

View File

@@ -0,0 +1,5 @@
class AddCustomerTermsAndConditionsAccepted < ActiveRecord::Migration
def change
add_column :customers, :terms_and_conditions_accepted_at, :datetime
end
end

View File

@@ -47,16 +47,17 @@ ActiveRecord::Schema.define(version: 20200912190210) do
add_index "coordinator_fees", ["order_cycle_id"], name: "index_coordinator_fees_on_order_cycle_id", using: :btree
create_table "customers", force: true do |t|
t.string "email", null: false
t.integer "enterprise_id", null: false
t.string "email", null: false
t.integer "enterprise_id", null: false
t.string "code"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "bill_address_id"
t.integer "ship_address_id"
t.string "name"
t.boolean "allow_charges", default: false, null: false
t.boolean "allow_charges", default: false, null: false
t.datetime "terms_and_conditions_accepted_at"
end
add_index "customers", ["bill_address_id"], name: "index_customers_on_bill_address_id", using: :btree