Create trello card before purchasing
This commit is contained in:
@@ -42,23 +42,10 @@ get '/cart/delivery_destination' do
|
|||||||
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
||||||
end
|
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", "gift",
|
|
||||||
"recipient_name", "recipient_address", "recipient_place", "recipient_postal_code", "recipient_phone", "recipient_email"]
|
|
||||||
|
|
||||||
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
|
||||||
cart.delivery_destination.update_attributes(params)
|
|
||||||
cart.delivery_destination.save!
|
|
||||||
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
|
||||||
}
|
|
||||||
put '/cart/delivery_destination', &update_delivery_destination
|
|
||||||
post '/cart/delivery_destination', &update_delivery_destination
|
|
||||||
|
|
||||||
def report_to_trello(cart)
|
def report_to_trello(cart)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
@cart = cart
|
@cart = cart
|
||||||
board = Trello::Board.find(RibicaConfig.TRELLO_BOARD_NAME)
|
board = Trello::Board.find(RibicaConfig::TRELLO_BOARD_NAME)
|
||||||
list = board.lists.first
|
list = board.lists.first
|
||||||
card = Trello::Card.new
|
card = Trello::Card.new
|
||||||
card.list_id = list.id
|
card.list_id = list.id
|
||||||
@@ -69,6 +56,22 @@ def report_to_trello(cart)
|
|||||||
end
|
end
|
||||||
end
|
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", "gift",
|
||||||
|
"recipient_name", "recipient_address", "recipient_place", "recipient_postal_code", "recipient_phone", "recipient_email"]
|
||||||
|
|
||||||
|
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
||||||
|
cart.delivery_destination.update_attributes(params)
|
||||||
|
cart.delivery_destination.save!
|
||||||
|
|
||||||
|
report_to_trello(cart)
|
||||||
|
|
||||||
|
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
||||||
|
}
|
||||||
|
put '/cart/delivery_destination', &update_delivery_destination
|
||||||
|
post '/cart/delivery_destination', &update_delivery_destination
|
||||||
|
|
||||||
def send_order_email(cart)
|
def send_order_email(cart)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
client = SendGrid::Client.new(
|
client = SendGrid::Client.new(
|
||||||
@@ -98,7 +101,7 @@ post '/cart/confirmation' do
|
|||||||
# since there is no more ordered cart this needs to be done
|
# since there is no more ordered cart this needs to be done
|
||||||
# in order for next call of Cart#just_find to be ready
|
# in order for next call of Cart#just_find to be ready
|
||||||
Cart.find_or_create(anonymous, logged_in_user_id)
|
Cart.find_or_create(anonymous, logged_in_user_id)
|
||||||
report_to_trello(cart)
|
#report_to_trello(cart)
|
||||||
send_order_email(cart)
|
send_order_email(cart)
|
||||||
"OK".to_json
|
"OK".to_json
|
||||||
end
|
end
|
||||||
@@ -120,7 +123,7 @@ post '/payment/confirmation' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
Cart.find_or_create(anonymous, user)
|
Cart.find_or_create(anonymous, user)
|
||||||
report_to_trello(cart)
|
#report_to_trello(cart)
|
||||||
send_order_email(cart)
|
send_order_email(cart)
|
||||||
"OK".to_json
|
"OK".to_json
|
||||||
end
|
end
|
||||||
@@ -138,7 +141,7 @@ get '/pikpay/confirmation' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
Cart.find_or_create(anonymous, user)
|
Cart.find_or_create(anonymous, user)
|
||||||
report_to_trello(cart)
|
#report_to_trello(cart)
|
||||||
send_order_email(cart)
|
send_order_email(cart)
|
||||||
|
|
||||||
redirect "#{RibicaConfig::ROOT_ADDRESS}/hvala"
|
redirect "#{RibicaConfig::ROOT_ADDRESS}/hvala"
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ Bosna i Hercegovina
|
|||||||
|
|
||||||
**Naručeno:** <%= @cart.updated_at.in_time_zone("Europe/Sarajevo").strftime("%A %d.%m.%Y. %H:%M") %>
|
**Naručeno:** <%= @cart.updated_at.in_time_zone("Europe/Sarajevo").strftime("%A %d.%m.%Y. %H:%M") %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<% if dd.instant_delivery %>
|
<% if dd.instant_delivery %>
|
||||||
** OVO JE NARUDŽBA ZA INSTANT DOSTAVU **
|
** OVO JE NARUDŽBA ZA INSTANT DOSTAVU **
|
||||||
|
|||||||
Reference in New Issue
Block a user