mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
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:
@@ -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'))
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddCustomerTermsAndConditionsAccepted < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :customers, :terms_and_conditions_accepted_at, :datetime
|
||||
end
|
||||
end
|
||||
11
db/schema.rb
11
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
|
||||
|
||||
Reference in New Issue
Block a user