diff --git a/app/views/checkout/_terms_and_conditions.html.haml b/app/views/checkout/_terms_and_conditions.html.haml index 6bafd6bbb7..0352ce804f 100644 --- a/app/views/checkout/_terms_and_conditions.html.haml +++ b/app/views/checkout/_terms_and_conditions.html.haml @@ -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')) diff --git a/db/migrate/20200907140555_add_customer_terms_and_conditions_accepted.rb b/db/migrate/20200907140555_add_customer_terms_and_conditions_accepted.rb new file mode 100644 index 0000000000..c48b1c19f2 --- /dev/null +++ b/db/migrate/20200907140555_add_customer_terms_and_conditions_accepted.rb @@ -0,0 +1,5 @@ +class AddCustomerTermsAndConditionsAccepted < ActiveRecord::Migration + def change + add_column :customers, :terms_and_conditions_accepted_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 5f982a1216..30247daf3a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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