effective_memberships 0.1.5 → 0.1.6

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: 99f08d66833ddda5de88911b43a3bdbeec7a3c8471a8018612dad529c577d8bd
4
- data.tar.gz: 0de87e5740113cde0a6dc6447eae0d53341637b6eeac1787ec233dceeab5b50c
3
+ metadata.gz: 94c86611361e96c3285e00fde6075fcffa29463c30a7dd2b50eaec13b9932874
4
+ data.tar.gz: faaa7786c43295547b10febc3c6f55b1e4041235d693f6f7e02094c22780f5af
5
5
  SHA512:
6
- metadata.gz: 4e7dbbdfccb1c6dc0f0c30f15c58fa04a82a556cf00d9ad00e252fcfd99c29c5b74a973a694c9447f19cf1b114d15a59decc1ac52049fc3019425c252938f7b7
7
- data.tar.gz: '0683eee612f3d51e1024c118813cce613a3f5715c2959ac09b7cbea1cb000e9c17e3acfced1deaf28c717a6398b0d1a26622394018a2ff3f4f3225de7fb58c90'
6
+ metadata.gz: b9c66aaa1fe570f885d5b36b83f733cf15f8b4d3e2a1968d5bd4db197cbddd33a91247405a60fde9ab5dbde210de04119d3f51594baf09946a7ebdcc8c29029d
7
+ data.tar.gz: 3b36dee1f865804437f63415680c49c131b9ee94a4ae7f8e31e2df789268ae413e43ea8db3ea8c8548e352a63cf33273b508832dcd1eb476ae877c19c8bcdc50
@@ -24,8 +24,9 @@ module Effective
24
24
 
25
25
  def permitted_params
26
26
  permitted = params.require(:effective_applicant_reference).permit!.except(:token, :last_notified_at, :status, :status_steps)
27
+ authorized = current_user.effective_memberships_owners.include?(resource.applicant.owner) == false
27
28
 
28
- if resource.submitted? && resource.applicant.was_submitted? && (resource.applicant.owner != current_user.effective_memberships_owner)
29
+ if resource.submitted? && resource.applicant.was_submitted? && authorized
29
30
  permitted
30
31
  else
31
32
  permitted.except(:reservations, :reservations_reason, :work_history, :accept_declaration)
@@ -4,7 +4,7 @@ module Effective
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope -> { EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owner) }
7
+ resource_scope -> { EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owners) }
8
8
 
9
9
  # Allow only 1 in-progress application at a time
10
10
  before_action(only: [:new, :show], unless: -> { resource&.done? }) do
@@ -4,7 +4,7 @@ module Effective
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope -> { EffectiveMemberships.FeePayment.deep.where(owner: current_user.effective_memberships_owner) }
7
+ resource_scope -> { EffectiveMemberships.FeePayment.deep.where(owner: current_user.effective_memberships_owners) }
8
8
 
9
9
  # Allow only 1 in-progress fee payment at a time
10
10
  before_action(only: [:new, :show], unless: -> { resource&.done? }) do
@@ -20,8 +20,7 @@ module Effective
20
20
 
21
21
  def permitted_params
22
22
  params.require(:fee_payment).permit!.except(
23
- :owner_id, :owner_type, :status, :status_steps, :wizard_steps,
24
- :submitted_at
23
+ :status, :status_steps, :wizard_steps, :submitted_at
25
24
  )
26
25
  end
27
26
 
@@ -28,7 +28,7 @@ class EffectiveApplicantsDatatable < Effective::Datatable
28
28
  end
29
29
 
30
30
  collection do
31
- EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owner)
31
+ EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owners)
32
32
  end
33
33
 
34
34
  end
@@ -6,24 +6,19 @@ class EffectiveFeePaymentsDatatable < Effective::Datatable
6
6
  col :token, visible: false
7
7
  col :created_at, visible: false
8
8
 
9
- col :status
10
- col :period, visible: false
9
+ col :owner
10
+ col :status, visible: false
11
11
  col :submitted_at, label: 'Submitted', as: :date
12
+ col :period, visible: false
12
13
 
13
- col :orders
14
+ col :orders, action: :show
14
15
 
15
- actions_col(show: false) do |fee_payment|
16
- if fee_payment.draft?
17
- dropdown_link_to('Continue', effective_memberships.fee_payment_build_path(fee_payment, fee_payment.next_step), 'data-turbolinks' => false)
18
- dropdown_link_to('Delete', effective_memberships.fee_payment_path(fee_payment), 'data-confirm': "Really delete #{fee_payment}?", 'data-method': :delete)
19
- else
20
- dropdown_link_to('Show', effective_memberships.fee_payment_path(fee_payment))
21
- end
22
- end
16
+ actions_col(new: false)
23
17
  end
24
18
 
25
19
  collection do
26
- EffectiveMemberships.FeePayment.deep.where(owner: current_user.effective_memberships_owner)
20
+ EffectiveMemberships.FeePayment.deep.done
21
+ .where(owner: current_user.effective_memberships_owners)
27
22
  end
28
23
 
29
24
  end
@@ -244,7 +244,6 @@ module EffectiveMembershipsFeePayment
244
244
  save!
245
245
  end
246
246
 
247
-
248
247
  # Called automatically via after_purchase hook above
249
248
  def submit_purchased!
250
249
  return false if was_submitted?
@@ -46,7 +46,23 @@ module EffectiveMembershipsOwner
46
46
  end
47
47
 
48
48
  def effective_memberships_owner
49
- self
49
+ raise('expected singular usage but there are more than one owner') if effective_memberships_owners.length > 1
50
+ effective_memberships_owners.first
51
+ end
52
+
53
+ def effective_memberships_owners
54
+ owners = users if respond_to?(:users) && users.any? { |user| user.class.respond_to?(:effective_memberships_owner?) }
55
+ owners = organizations if respond_to?(:organizations) && organizations.any? { |organization| organization.class.respond_to?(:effective_memberships_owner?) }
56
+
57
+ owners || [self]
58
+ end
59
+
60
+ def outstanding_fee_payment_owners
61
+ effective_memberships_owners.select { |owner| !owner.membership_fees_paid? }
62
+ end
63
+
64
+ def current_fee_payment_owner
65
+ outstanding_fee_payment_owners.first || self
50
66
  end
51
67
 
52
68
  def owner_label
@@ -1,6 +1,4 @@
1
- - authorized = EffectiveResources.authorized?(self, :new, EffectiveMemberships.FeePayment)
2
- - datatable = EffectiveResources.best('EffectiveFeePaymentsDatatable').new(self)
3
- - in_progress = current_user.effective_memberships_owner.fee_payments.in_progress
1
+ - datatable = EffectiveResources.best('EffectiveFeePaymentsDatatable').new(self, namespace: :effective)
4
2
 
5
3
  %h2 Fee Payments
6
4
 
@@ -2,19 +2,33 @@
2
2
 
3
3
  .card
4
4
  .card-body
5
- %p Welcome #{current_user.effective_memberships_owner}!
5
+ - current_owner = current_user.current_fee_payment_owner
6
+
7
+ %p Welcome #{current_owner}!
6
8
 
7
9
  = render 'effective/fee_payments/content', resource: resource
8
10
 
9
- - if resource.outstanding_fees.blank?
11
+ - if current_owner.membership_fees_paid?
10
12
  %p You have no fees due at this time.
11
13
  = link_to 'Home', root_path, class: 'btn btn-primary'
12
14
 
13
- - if resource.outstanding_fees.present?
14
- %p You have the following fees due at this time:
15
+ - else
16
+ - if resource.outstanding_fees.present?
17
+ %p You have the following fees due at this time:
18
+ = render_purchasables(resource.outstanding_fees)
19
+ - else
20
+ %p You have fees due. Please continue.
15
21
 
16
- = render_purchasables(resource.outstanding_fees)
22
+ - resource.user = current_user
23
+ - resource.owner = current_owner
17
24
 
18
25
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
19
26
  = f.hidden_field :id
27
+
28
+ = f.hidden_field :owner_type
29
+ = f.hidden_field :owner_id
30
+
31
+ = f.hidden_field :user_type
32
+ = f.hidden_field :user_id
33
+
20
34
  = f.save 'Save and Continue'
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_memberships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
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-12-21 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails