Gift interface added
This commit is contained in:
@@ -44,7 +44,7 @@ end
|
||||
|
||||
update_delivery_destination = ->() {
|
||||
cart = Cart.just_find(anonymous_id, logged_in_user_id)
|
||||
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note", "payment_method"]
|
||||
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note", "payment_method", "gift"]
|
||||
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
||||
cart.delivery_destination.update_attributes(params)
|
||||
cart.delivery_destination.save!
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddRecipientAddressToCart < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :carts, :recipient_destination_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddGiftToDeliveryDestination < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :delivery_destinations, :gift, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160111024541) do
|
||||
ActiveRecord::Schema.define(version: 20160111105607) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -22,17 +22,18 @@ ActiveRecord::Schema.define(version: 20160111024541) do
|
||||
|
||||
create_table "carts", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.boolean "ordered", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "ordered", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "anonymous_id_string"
|
||||
t.integer "delivery_destination_id"
|
||||
t.boolean "confirmed", default: false
|
||||
t.boolean "packed", default: false
|
||||
t.boolean "canceled_on_check", default: false
|
||||
t.boolean "canceled_on_delivery", default: false
|
||||
t.boolean "delivered", default: false
|
||||
t.boolean "confirmed", default: false
|
||||
t.boolean "packed", default: false
|
||||
t.boolean "canceled_on_check", default: false
|
||||
t.boolean "canceled_on_delivery", default: false
|
||||
t.boolean "delivered", default: false
|
||||
t.text "internal_note"
|
||||
t.integer "recipient_destination_id"
|
||||
end
|
||||
|
||||
create_table "categories", force: :cascade do |t|
|
||||
@@ -68,6 +69,7 @@ ActiveRecord::Schema.define(version: 20160111024541) do
|
||||
t.string "anonymous_id_string"
|
||||
t.boolean "instant_delivery", default: false
|
||||
t.string "payment_method"
|
||||
t.boolean "gift", default: false
|
||||
end
|
||||
|
||||
create_table "delivery_time_estimations", force: :cascade do |t|
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class Cart < ActiveRecord::Base
|
||||
has_many :item_in_carts, -> { order "created_at" }
|
||||
belongs_to :delivery_destination
|
||||
|
||||
belongs_to :delivery_destination, :class_name => 'DeliveryDestination', :foreign_key => 'delivery_destination_id'
|
||||
belongs_to :delivery_destination, :class_name => 'DeliveryDestination', :foreign_key => 'recipient_destination_id'
|
||||
|
||||
def self.find_or_create(anonymous_id, user_id)
|
||||
cart = nil
|
||||
@@ -74,7 +76,7 @@ class Cart < ActiveRecord::Base
|
||||
|
||||
def title
|
||||
number = id
|
||||
name = delivery_destination.name
|
||||
name = delivery_destination.name
|
||||
value = Helper.money(total)
|
||||
phone = "0#{delivery_destination.phone}"
|
||||
"BR: #{number} za #{name} (#{phone}) - #{value}"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class DeliveryDestination < ActiveRecord::Base
|
||||
has_one :cart
|
||||
has_many :carts
|
||||
belongs_to :user
|
||||
|
||||
def self.create_from_last(anonymous_id, user_id)
|
||||
|
||||
Reference in New Issue
Block a user