effective_memberships 0.6.5 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/admin/registrar_actions_controller.rb +4 -4
- data/app/models/concerns/effective_memberships_applicant.rb +9 -3
- data/app/models/concerns/effective_memberships_registrar.rb +47 -20
- data/app/models/effective/membership.rb +8 -0
- data/app/models/effective/registrar_action.rb +14 -9
- data/app/views/admin/registrar_actions/_form_status_change.html.haml +15 -10
- data/app/views/effective/applicants/_summary.html.haml +5 -1
- data/app/views/effective/applicants/select/_apply_for_reinstatement.html.haml +1 -1
- data/db/seeds.rb +2 -0
- data/lib/effective_memberships/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1fcdc5cbf08b23f6aab670babdf698a2aff6b6d9d2067055dc970bb2eb4b8e4
|
4
|
+
data.tar.gz: 0a423a28dc16bd84135e741bcb9f290c7997c034ba0095319bab4cf36913d605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 296aa3d82c05315ac9247f28052e474440562fb85450fc4735f4875b26d67ccdd612df58727207251f2540f103efa41c519128e1366be02f446400816000f3de
|
7
|
+
data.tar.gz: 71feca7c490aea3f2ba49cae7c3318b79d5da533f1b7a6adedcb0ae38a1b9ea2c6b61daa163a9abfc92e2d3e8aff110dbb705c4e373bcfab488aae1d9533a82c
|
@@ -14,16 +14,16 @@ module Admin
|
|
14
14
|
success: -> { "#{resource.owner} has been reclassified to #{resource.owner.membership.category}" },
|
15
15
|
redirect: -> { admin_owners_path(resource) }
|
16
16
|
|
17
|
-
submit :
|
18
|
-
success: -> { "#{resource.owner} has been
|
17
|
+
submit :status_assign, 'Assign Status',
|
18
|
+
success: -> { "#{resource.owner} has been assigned #{resource.owner.membership.statuses_sentence}" },
|
19
19
|
redirect: -> { admin_owners_path(resource) }
|
20
20
|
|
21
21
|
submit :status_remove, 'Remove Status',
|
22
|
-
success: -> { "#{resource.owner} has
|
22
|
+
success: -> { "#{resource.owner} has been removed from #{resource.status}" },
|
23
23
|
redirect: -> { admin_owners_path(resource) }
|
24
24
|
|
25
25
|
submit :assign, 'Assign',
|
26
|
-
success: -> { "#{resource.owner} has been assigned to #{resource.owner.membership.
|
26
|
+
success: -> { "#{resource.owner} has been assigned to #{resource.owner.membership.categories_sentence}" },
|
27
27
|
redirect: -> { admin_owners_path(resource) }
|
28
28
|
|
29
29
|
submit :remove, 'Remove',
|
@@ -194,8 +194,14 @@ module EffectiveMembershipsApplicant
|
|
194
194
|
# Set Apply to Join or Reclassification
|
195
195
|
before_validation(if: -> { (new_record? || current_step == :select) && owner.present? }) do
|
196
196
|
self.applicant_type ||= can_apply_applicant_types_collection().first
|
197
|
-
|
198
|
-
|
197
|
+
|
198
|
+
if owner.membership.present?
|
199
|
+
self.from_category = owner.membership.categories.first
|
200
|
+
end
|
201
|
+
|
202
|
+
if owner.membership.present? && reinstatement?
|
203
|
+
self.from_status = owner.membership.statuses.find { |status| status.reinstatable? }
|
204
|
+
end
|
199
205
|
end
|
200
206
|
|
201
207
|
before_validation(if: -> { current_step == :experience }) do
|
@@ -779,7 +785,7 @@ module EffectiveMembershipsApplicant
|
|
779
785
|
elsif reclassification?
|
780
786
|
EffectiveMemberships.Registrar.reclassify!(owner, to: category)
|
781
787
|
elsif reinstatement?
|
782
|
-
EffectiveMemberships.Registrar.reinstate!(owner)
|
788
|
+
EffectiveMemberships.Registrar.reinstate!(owner, from: from_status)
|
783
789
|
else
|
784
790
|
raise('unsupported approval applicant_type')
|
785
791
|
end
|
@@ -186,17 +186,18 @@ module EffectiveMembershipsRegistrar
|
|
186
186
|
save!(owner, date: date)
|
187
187
|
end
|
188
188
|
|
189
|
-
def reinstate!(owner, date: nil, skip_fees: false)
|
189
|
+
def reinstate!(owner, from:, date: nil, skip_fees: false)
|
190
190
|
raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
|
191
191
|
raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
|
192
192
|
|
193
|
-
from
|
194
|
-
raise('
|
193
|
+
raise('expecting a from') if from.blank?
|
194
|
+
raise('expected a from status or category') unless from.class.respond_to?(:effective_memberships_status?) || from.class.respond_to?(:effective_memberships_category?)
|
195
195
|
|
196
196
|
date ||= Time.zone.now
|
197
197
|
|
198
198
|
membership = owner.membership
|
199
|
-
membership.membership_status(status: from).mark_for_destruction if from.
|
199
|
+
membership.membership_status(status: from).mark_for_destruction if from.class.respond_to?(:effective_memberships_status?)
|
200
|
+
membership.membership_category(category: from).mark_for_destruction if from.class.respond_to?(:effective_memberships_category?)
|
200
201
|
|
201
202
|
unless skip_fees
|
202
203
|
fee = owner.build_prorated_fee(date: date)
|
@@ -206,37 +207,63 @@ module EffectiveMembershipsRegistrar
|
|
206
207
|
save!(owner, date: date)
|
207
208
|
end
|
208
209
|
|
209
|
-
|
210
|
-
|
211
|
-
|
210
|
+
def status_clear!(owner, date: nil)
|
211
|
+
raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
|
212
|
+
raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
|
213
|
+
|
214
|
+
status_assign!(owner, date: date, status: [])
|
212
215
|
end
|
213
216
|
|
214
|
-
|
215
|
-
def status_change!(owner, to:, date: nil)
|
217
|
+
def status_add!(owner, status:, date: nil)
|
216
218
|
raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
|
217
219
|
raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
|
218
220
|
|
219
|
-
|
221
|
+
status_assign!(owner, date: date, status: owner.membership.statuses + Array(status))
|
222
|
+
end
|
220
223
|
|
221
|
-
|
222
|
-
raise('expecting a
|
223
|
-
raise('
|
224
|
+
def status_remove!(owner, status:, date: nil)
|
225
|
+
raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
|
226
|
+
raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
|
224
227
|
|
225
|
-
date
|
228
|
+
status_assign!(owner, date: date, status: owner.membership.statuses - Array(status))
|
229
|
+
end
|
230
|
+
|
231
|
+
def status_assign!(owner, status:, date: nil)
|
232
|
+
raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
|
226
233
|
|
227
234
|
membership = owner.membership
|
235
|
+
raise('owner must have an existing membership. use register! instead') if membership.blank?
|
228
236
|
|
229
|
-
|
230
|
-
|
231
|
-
membership.membership_status(status: from).mark_for_destruction if from.present?
|
237
|
+
statuses = Array(status)
|
238
|
+
raise('expected a memberships status') unless statuses.blank? || statuses.all? { |status| status.class.respond_to?(:effective_memberships_status?) }
|
232
239
|
|
233
|
-
#
|
234
|
-
|
240
|
+
# Add
|
241
|
+
statuses.each do |status|
|
242
|
+
next if membership.membership_status(status: status).present?
|
243
|
+
membership.build_membership_status(status: status)
|
244
|
+
end
|
245
|
+
|
246
|
+
# Remove
|
247
|
+
membership.statuses.each do |existing|
|
248
|
+
next if statuses.include?(existing)
|
249
|
+
membership.membership_status(status: existing).mark_for_destruction
|
250
|
+
end
|
251
|
+
|
252
|
+
changed = membership.membership_statuses.any? { |ms| ms.new_record? || ms.marked_for_destruction? }
|
253
|
+
|
254
|
+
if changed
|
255
|
+
date ||= Time.zone.now
|
256
|
+
|
257
|
+
membership.registration_on = date # Always new registration_on
|
258
|
+
save!(owner, date: date)
|
259
|
+
end
|
260
|
+
|
261
|
+
true
|
235
262
|
end
|
236
263
|
|
237
264
|
def remove!(owner, date: nil)
|
238
265
|
raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
|
239
|
-
raise('expected a member') unless owner.membership.present?
|
266
|
+
raise('expected a member with a membership') unless owner.membership.present?
|
240
267
|
|
241
268
|
# Date
|
242
269
|
date ||= Time.zone.now
|
@@ -113,6 +113,10 @@ module Effective
|
|
113
113
|
categories.first.id
|
114
114
|
end
|
115
115
|
|
116
|
+
def categories_sentence
|
117
|
+
categories.map(&:to_s).to_sentence.presence || 'None'
|
118
|
+
end
|
119
|
+
|
116
120
|
def membership_category(category:)
|
117
121
|
raise('expected a category') unless category.class.respond_to?(:effective_memberships_category?)
|
118
122
|
membership_categories.find { |mc| mc.category_id == category.id && mc.category_type == category.class.name }
|
@@ -134,6 +138,10 @@ module Effective
|
|
134
138
|
membership_statuses.reject(&:marked_for_destruction?).map(&:status_id)
|
135
139
|
end
|
136
140
|
|
141
|
+
def statuses_sentence
|
142
|
+
statuses.map(&:to_s).to_sentence.presence || 'None'
|
143
|
+
end
|
144
|
+
|
137
145
|
# We might want to use singular memberships.
|
138
146
|
def status
|
139
147
|
raise('expected singular usage but there are more than one membership status') if statuses.length > 1
|
@@ -21,8 +21,8 @@ module Effective
|
|
21
21
|
attr_accessor :skip_fees
|
22
22
|
|
23
23
|
# Status Change
|
24
|
+
attr_accessor :status_ids
|
24
25
|
attr_accessor :status_id
|
25
|
-
attr_accessor :status_remove_action
|
26
26
|
|
27
27
|
# Assign
|
28
28
|
attr_accessor :category_ids
|
@@ -46,8 +46,11 @@ module Effective
|
|
46
46
|
validates :category_id, presence: true,
|
47
47
|
if: -> { current_action == :reclassify || current_action == :register }
|
48
48
|
|
49
|
-
# Status
|
50
|
-
validates :
|
49
|
+
# Status Assign
|
50
|
+
validates :status_ids, presence: true, if: -> { current_action == :status_assign }
|
51
|
+
|
52
|
+
# Status Remove
|
53
|
+
validates :status_id, presence: true, if: -> { current_action == :status_remove }
|
51
54
|
|
52
55
|
# Assign
|
53
56
|
validates :category_ids, presence: true, if: -> { current_action == :assign }
|
@@ -66,14 +69,14 @@ module Effective
|
|
66
69
|
EffectiveMemberships.Registrar.reclassify!(owner, to: category, skip_fees: skip_fees?)
|
67
70
|
end
|
68
71
|
|
69
|
-
def
|
70
|
-
update!(current_action: :
|
71
|
-
EffectiveMemberships.Registrar.
|
72
|
+
def status_assign!
|
73
|
+
update!(current_action: :status_assign)
|
74
|
+
EffectiveMemberships.Registrar.status_assign!(owner, status: statuses)
|
72
75
|
end
|
73
76
|
|
74
77
|
def status_remove!
|
75
78
|
update!(current_action: :status_remove)
|
76
|
-
EffectiveMemberships.Registrar.status_remove!(owner)
|
79
|
+
EffectiveMemberships.Registrar.status_remove!(owner, status: status)
|
77
80
|
end
|
78
81
|
|
79
82
|
def assign!
|
@@ -101,6 +104,10 @@ module Effective
|
|
101
104
|
EffectiveMemberships.Registrar.remove!(owner)
|
102
105
|
end
|
103
106
|
|
107
|
+
def assign_attributes(atts)
|
108
|
+
super(atts.reject { |k, _| k.to_s.start_with?('status_remove_action_') })
|
109
|
+
end
|
110
|
+
|
104
111
|
def update!(atts)
|
105
112
|
assign_attributes(atts); save!
|
106
113
|
end
|
@@ -121,8 +128,6 @@ module Effective
|
|
121
128
|
@owner_id || (@owner.id if @owner)
|
122
129
|
end
|
123
130
|
|
124
|
-
private
|
125
|
-
|
126
131
|
def category
|
127
132
|
EffectiveMemberships.Category.find(@category_id) if @category_id.present?
|
128
133
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
%h5.card-title Status Change
|
4
4
|
|
5
5
|
= effective_form_with(model: [:admin, registrar_action], url: effective_memberships.admin_registrar_actions_path) do |f|
|
6
|
+
|
6
7
|
= f.hidden_field :owner_id
|
7
8
|
= f.hidden_field :owner_type
|
8
9
|
|
@@ -13,29 +14,33 @@
|
|
13
14
|
Change or remove a member's existing status.
|
14
15
|
|
15
16
|
= f.static_field :current_action, label: 'Current Status' do
|
16
|
-
= (membership.
|
17
|
+
= badges(membership.statuses) || 'None'
|
17
18
|
|
18
19
|
= f.check_box :current_action, label: 'Yes, change member status'
|
19
20
|
|
20
21
|
= f.show_if :current_action, true do
|
21
22
|
%p The member will keep their existing membership number: #{membership.number}.
|
22
23
|
|
23
|
-
- statuses = f.object.owner.registrar_action_statuses(:status_change)
|
24
|
-
|
24
|
+
- statuses = f.object.owner.registrar_action_statuses(:status_change)
|
25
|
+
- f.object.status_ids = membership.status_ids
|
26
|
+
|
27
|
+
= f.select :status_ids, statuses, label: 'Change status to', required: true, multiple: true
|
25
28
|
|
26
29
|
%p No fees will be created
|
27
30
|
|
28
|
-
= f.submit '
|
31
|
+
= f.submit 'Assign Status', border: false, center: true, 'data-confirm': "Really assign #{f.object.owner} status?"
|
32
|
+
|
33
|
+
- # Remove Actions
|
34
|
+
- membership.statuses.each do |status|
|
35
|
+
= f.check_box "status_remove_action_#{status.id}", label: "Yes, remove #{status} status"
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
= f.check_box :status_remove_action, label: "Yes, remove #{membership.status} status"
|
37
|
+
= f.show_if("status_remove_action_#{status.id}", true, validate: false) do
|
38
|
+
= f.hidden_field :status_id, value: status.id
|
33
39
|
|
34
|
-
= f.show_if :status_remove_action, true do
|
35
40
|
%p The member will keep their existing membership number: #{membership.number}
|
36
41
|
|
37
|
-
%p This action will remove the #{
|
42
|
+
%p This action will remove the #{badge(status)} status
|
38
43
|
|
39
44
|
%p No fees will be created
|
40
45
|
|
41
|
-
= f.submit
|
46
|
+
= f.submit "Remove Status", border: false, center: true, 'data-confirm': "Remove #{status} from #{f.object.owner}?"
|
@@ -22,7 +22,11 @@
|
|
22
22
|
- else
|
23
23
|
None
|
24
24
|
|
25
|
-
- if applicant.
|
25
|
+
- if applicant.from_status.present?
|
26
|
+
%tr
|
27
|
+
%th From Status
|
28
|
+
%td= applicant.from_status
|
29
|
+
- elsif applicant.from_category.present?
|
26
30
|
%tr
|
27
31
|
%th From Category
|
28
32
|
%td= applicant.from_category
|
data/db/seeds.rb
CHANGED
@@ -10,6 +10,8 @@ if Rails.env.test?
|
|
10
10
|
end
|
11
11
|
|
12
12
|
Effective::Status.where(title: 'Resigned').first_or_create!
|
13
|
+
Effective::Status.where(title: 'Deceased').first_or_create!
|
14
|
+
Effective::Status.where(title: 'On Leave').first_or_create!
|
13
15
|
|
14
16
|
member = Effective::Category.create!(
|
15
17
|
title: "Full Member",
|
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.6.
|
4
|
+
version: 0.6.8
|
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: 2022-09-
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|