effective_orders 5.2.1 → 5.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b2e8598ea6f759b602e70d61c5942080c2e528fc8c123b93e3396cbc2a8a26a
4
- data.tar.gz: 004e0db3016e081294d9c6fe49a02eb800a13f49f7917f0d83c445e5a615ebdc
3
+ metadata.gz: cc1c2f6fea7135b9b7578bef447c14f3485fd68cef06a2c441c17c08fcce5628
4
+ data.tar.gz: eedc4248429fafb164669fb64a03b0119ae2bbd806847a8022670c0da947ffc9
5
5
  SHA512:
6
- metadata.gz: 071a7b38a0c5817e3165ac17b2193288e435b0e92c3a54163bfa7997c7132f9f5c02329421198ad51e9078dc351e77a5984aafa96a2f51bef518913886bf0870
7
- data.tar.gz: d2825cd0a8f2c66c6975bcdaf926ab9ac35081383547ad41965813d26a4d2ea059426340a1bba723f22f1ada37c19d2e16a0d34c23423189981fb8611ffdbbbd
6
+ metadata.gz: 7b7955c3e945f81015f7f3958cd70ccb80dc55fc935c7e29043a4f2b2174c700c42f9bf32dc322b3743cc2ec5d1b1c38682a24dfcf6322cd631315b63d99b049
7
+ data.tar.gz: 06e6e17294699a973be1d3b34a6cf0a5d97623e9e9523e9a618113f783bd7ffbefce7d2dd8ec113139feb35d69d120130ca6adb8c917c18f598439adf83012ae
@@ -93,7 +93,10 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
93
93
  end
94
94
 
95
95
  if attributes[:user_id].present?
96
- user = current_user.class.find(attributes[:user_id])
96
+ user_klass = (attributes[:user_type].constantize if attributes[:user_type].present?)
97
+ user_klass ||= current_user.class
98
+
99
+ user = user_klass.find(attributes[:user_id])
97
100
  scope = scope.where(user: user)
98
101
  end
99
102
 
@@ -62,7 +62,10 @@ class EffectiveOrdersDatatable < Effective::Datatable
62
62
  end
63
63
 
64
64
  collection do
65
- user = current_user.class.find(attributes[:user_id])
65
+ user_klass = (attributes[:user_type].constantize if attributes[:user_type].present?)
66
+ user_klass ||= current_user.class
67
+
68
+ user = user_klass.find(attributes[:user_id])
66
69
 
67
70
  scope = Effective::Order.all.deep.where(user: user)
68
71
 
@@ -459,13 +459,16 @@ module Effective
459
459
  self.payment = payment_to_h(payment) if self.payment.blank?
460
460
 
461
461
  begin
462
- Effective::Order.transaction do
462
+ EffectiveResources.transaction do
463
463
  run_purchasable_callbacks(:before_purchase)
464
+
464
465
  save!
465
466
  update_purchasables_purchased_order!
467
+
468
+ run_purchasable_callbacks(:after_purchase)
466
469
  end
467
470
  rescue => e
468
- Effective::Order.transaction do
471
+ EffectiveResources.transaction do
469
472
  save!(validate: false)
470
473
  update_purchasables_purchased_order!
471
474
  end
@@ -473,7 +476,6 @@ module Effective
473
476
  raise(e)
474
477
  end
475
478
 
476
- run_purchasable_callbacks(:after_purchase)
477
479
  send_order_receipts! if email
478
480
 
479
481
  true
@@ -506,9 +508,11 @@ module Effective
506
508
  skip_buyer_validations: true
507
509
  )
508
510
 
509
- Effective::Order.transaction do
511
+ EffectiveResources.transaction do
510
512
  begin
513
+ run_purchasable_callbacks(:before_decline)
511
514
  save!(validate: validate)
515
+ run_purchasable_callbacks(:after_decline)
512
516
  rescue => e
513
517
  self.state = state_was
514
518
 
@@ -519,8 +523,6 @@ module Effective
519
523
 
520
524
  raise "Failed to decline order: #{error || errors.full_messages.to_sentence}" unless error.nil?
521
525
 
522
- run_purchasable_callbacks(:after_decline)
523
-
524
526
  true
525
527
  end
526
528
 
@@ -637,8 +639,15 @@ module Effective
637
639
  end
638
640
 
639
641
  def run_purchasable_callbacks(name)
640
- order_items.each { |oi| oi.purchasable.public_send(name, self, oi) if oi.purchasable.respond_to?(name) }
641
- parent.public_send(name, self) if parent.respond_to?(name)
642
+ order_items.select { |item| item.purchasable.respond_to?(name) }.each do |item|
643
+ EffectiveResources.transaction(item) { item.purchasable.public_send(name, self, item) }
644
+ end
645
+
646
+ if parent.respond_to?(name)
647
+ EffectiveResources.transaction(parent) { parent.public_send(name, self) }
648
+ end
649
+
650
+ true
642
651
  end
643
652
 
644
653
  def send_email(email, *args)
@@ -1,6 +1,7 @@
1
1
  = render partial: 'effective/orders/order', locals: { order: order }
2
2
 
3
- - if order.persisted? && order.user == current_user
3
+ - # Show this if I'm on the effective orders checkout screen. But not on a rendered order.
4
+ - if order.persisted? && order.user == current_user && request.path.to_s.start_with?(effective_orders.order_path(order))
4
5
  .effective-order-change-items
5
6
  = link_to 'Change Addresses', effective_orders.edit_order_path(order), rel: :nofollow, class: 'btn btn-secondary'
6
7
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.2.1'.freeze
2
+ VERSION = '5.2.5'.freeze
3
3
  end
@@ -116,7 +116,7 @@ module EffectiveOrders
116
116
 
117
117
  # The Effective::Order.payment_provider value must be in this collection
118
118
  def self.payment_providers
119
- @payment_providers ||= [
119
+ [
120
120
  ('cheque' if cheque?),
121
121
  ('credit card' if mark_as_paid?),
122
122
  ('free' if free?),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails