effective_memberships 0.9.14 → 0.9.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/admin/effective_fees_datatable.rb +3 -0
- data/app/models/concerns/effective_memberships_applicant.rb +1 -1
- data/app/models/concerns/effective_memberships_owner.rb +21 -2
- data/app/models/concerns/effective_memberships_registrar.rb +2 -21
- data/app/models/effective/membership.rb +30 -0
- data/app/views/effective/memberships/_dashboard.html.haml +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: 90078c67d46aca1f293b49ffacac17288bb24592a4007079e6843847845a4e48
|
4
|
+
data.tar.gz: 0063d4f68e0c2ff073c06eb62812006d13f050b50eecbc10163aa80f0a862a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01b87e4c9a1aa5664e5bb0fb14ca95a3fac57ea8f2ca0542e379e7e11a1d0450c7aef6fcd4b8d29ab3312e6db33e4a3729b60301b54870e0d7abe20f144df93b
|
7
|
+
data.tar.gz: e71ea11d0e5d126f4e37474726a234440f6e2105131a57fd1a6427c9c2ab897884f3502df0f2150a89318748b494d156a1e11d3fd81334aab8d9c19d9c2ef533
|
@@ -607,7 +607,7 @@ module EffectiveMembershipsApplicant
|
|
607
607
|
def can_apply_applicant_types_collection
|
608
608
|
if owner.blank?
|
609
609
|
['Apply to Join']
|
610
|
-
elsif owner.membership_removed?
|
610
|
+
elsif owner.membership_removed? && owner.reinstatement_membership_history.present?
|
611
611
|
['Apply for Reinstatement', 'Apply to Join']
|
612
612
|
elsif owner.membership.blank? || owner.membership.categories.blank?
|
613
613
|
['Apply to Join']
|
@@ -144,11 +144,11 @@ module EffectiveMembershipsOwner
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def reinstatement_membership_category
|
147
|
-
reinstatement_membership_history
|
147
|
+
reinstatement_membership_history&.membership_categories&.first
|
148
148
|
end
|
149
149
|
|
150
150
|
def reinstatement_membership_statuses
|
151
|
-
reinstatement_membership_history
|
151
|
+
reinstatement_membership_history&.membership_statuses
|
152
152
|
end
|
153
153
|
|
154
154
|
def registrar_action_categories(action)
|
@@ -333,6 +333,25 @@ module EffectiveMembershipsOwner
|
|
333
333
|
save!
|
334
334
|
end
|
335
335
|
|
336
|
+
# Delete the last membership history
|
337
|
+
def rollback_membership_history!
|
338
|
+
raise('expected membership to be present') unless membership.present?
|
339
|
+
|
340
|
+
(history, last) = membership_histories.last(2)
|
341
|
+
raise('expected 2 or more membership histories') unless history.present? && last.present?
|
342
|
+
|
343
|
+
last.mark_for_destruction
|
344
|
+
history.assign_attributes(end_on: nil)
|
345
|
+
|
346
|
+
membership.assign_attributes(
|
347
|
+
number: history.number,
|
348
|
+
categories: history.membership_categories,
|
349
|
+
statuses: history.membership_statuses
|
350
|
+
)
|
351
|
+
|
352
|
+
save!
|
353
|
+
end
|
354
|
+
|
336
355
|
def build_membership_history(start_on: nil, notes: nil)
|
337
356
|
raise('expected membership to be present') unless membership.present?
|
338
357
|
|
@@ -76,27 +76,8 @@ module EffectiveMembershipsRegistrar
|
|
76
76
|
membership.number ||= number
|
77
77
|
membership.number_as_integer ||= (Integer(number) rescue nil)
|
78
78
|
|
79
|
-
#
|
80
|
-
membership.
|
81
|
-
next if statuses.include?(membership_status.status)
|
82
|
-
membership_status.mark_for_destruction
|
83
|
-
end
|
84
|
-
|
85
|
-
# Build any additional statuses
|
86
|
-
statuses.each do |status|
|
87
|
-
membership.build_membership_status(status: status)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Delete any removed categories
|
91
|
-
membership.membership_categories.each do |membership_category|
|
92
|
-
next if categories.include?(membership_category.category)
|
93
|
-
membership_category.mark_for_destruction
|
94
|
-
end
|
95
|
-
|
96
|
-
# Build any additional categories
|
97
|
-
categories.each do |category|
|
98
|
-
membership.build_membership_category(category: category)
|
99
|
-
end
|
79
|
+
# Builds the membership_categories and membership_statuses. Marks for destruction ones that don't exist.
|
80
|
+
membership.assign_attributes(statuses: statuses, categories: categories)
|
100
81
|
|
101
82
|
changed = membership.membership_categories.any? { |mc| mc.new_record? || mc.marked_for_destruction? }
|
102
83
|
changed ||= membership.membership_statuses.any? { |ms| ms.new_record? || ms.marked_for_destruction? }
|
@@ -156,6 +156,21 @@ module Effective
|
|
156
156
|
membership_categories.reject(&:marked_for_destruction?).map(&:category_id)
|
157
157
|
end
|
158
158
|
|
159
|
+
def categories=(categories)
|
160
|
+
categories = Array(categories)
|
161
|
+
raise('expecting a membership category') if categories.any? { |cat| !cat.class.respond_to?(:effective_memberships_category?) }
|
162
|
+
|
163
|
+
# Delete any removed categories
|
164
|
+
membership_categories.each do |membership_category|
|
165
|
+
membership_category.mark_for_destruction unless categories.include?(membership_category.category)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Build any additional categories
|
169
|
+
categories.each { |category| build_membership_category(category: category) }
|
170
|
+
|
171
|
+
nil
|
172
|
+
end
|
173
|
+
|
159
174
|
# We might want to use singular memberships.
|
160
175
|
def category
|
161
176
|
raise('expected singular usage but there are more than one membership category') if categories.length > 1
|
@@ -192,6 +207,21 @@ module Effective
|
|
192
207
|
membership_statuses.reject(&:marked_for_destruction?).map(&:status_id)
|
193
208
|
end
|
194
209
|
|
210
|
+
def statuses=(statuses)
|
211
|
+
statuses = Array(statuses)
|
212
|
+
raise('expecting a membership category') if statuses.any? { |status| !status.class.respond_to?(:effective_memberships_status?) }
|
213
|
+
|
214
|
+
# Delete any removed statuses
|
215
|
+
membership_statuses.each do |membership_status|
|
216
|
+
membership_status.mark_for_destruction unless statuses.include?(membership_status.status)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Build any additional statuses
|
220
|
+
statuses.each { |status| build_membership_status(status: status) }
|
221
|
+
|
222
|
+
nil
|
223
|
+
end
|
224
|
+
|
195
225
|
def statuses_sentence
|
196
226
|
statuses.map(&:to_s).to_sentence.presence || 'None'
|
197
227
|
end
|
@@ -35,6 +35,8 @@
|
|
35
35
|
|
36
36
|
- if current_user.membership_removed?
|
37
37
|
%p Your membership was removed on #{current_user.membership_removed_on.strftime('%F')}.
|
38
|
+
|
39
|
+
- if current_user.reinstatement_membership_history.present?
|
38
40
|
%p You may Apply for Reinstatement to #{current_user.reinstatement_membership_category} by clicking the Apply to Join button below and then complete the wizard.
|
39
41
|
|
40
42
|
- if membership_organizations.present?
|
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.9.
|
4
|
+
version: 0.9.16
|
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: 2023-01-
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|