effective_memberships 0.6.3 → 0.6.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: 3d93c9f826d21228e86c0b10e7f30453ba7201dd00e9eab65f9b332850d4cfd6
4
- data.tar.gz: 75520c50d89f83b7f2f0657efcd3f581b058ab2af756640bccb6d5bf4fb66207
3
+ metadata.gz: d5a9ac211f2370d13d88ee7b8ce0345c4c8363c530dd60dccbe4bc2da046bf98
4
+ data.tar.gz: 69f0f40f0116c65bea68c949424921b2a87b821e50e664fc73b1312f90c79a79
5
5
  SHA512:
6
- metadata.gz: e63960291256ab28e1ae9e4a8e1949cabaf24d31ded3bdd2e74c5240ba6539431e24bf6bac5161f933b92243db98dde91cbada1f654ced95bd4725f0583d2677
7
- data.tar.gz: 20ac5d9b6a2f1021b2df5391aa6751f48061cd9c672709870eeb303e17205968d57121089b2d851596b4e2780fe2fa903f61cfeb9969aa91ab11202f03e7eb46
6
+ metadata.gz: 7edb8681ca649e8aa121cf38add83c1e21277a968682e8b183f5f3197a84dd061f5ebac01c0da824c64f59c93f47e17d46ea43d81ee4b31a1cb485235b24f7e7
7
+ data.tar.gz: 4fe46479e76c85a356861d4b42f2e1b59675c3726e61c9791044b85133679e87f5d2b66e7a719311fe6c15a6d25a89db04f2b4f20232c462c5a028cf2c013f85
@@ -195,7 +195,7 @@ module EffectiveMembershipsApplicant
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
197
  self.from_category = owner.membership&.category
198
- self.from_status = owner.membership&.status
198
+ self.from_status = owner.membership&.status if reinstatement?
199
199
  end
200
200
 
201
201
  before_validation(if: -> { current_step == :experience }) do
@@ -559,7 +559,7 @@ module EffectiveMembershipsApplicant
559
559
  def can_apply_applicant_types_collection
560
560
  if owner.blank? || owner.membership.blank? || owner.membership.categories.blank?
561
561
  ['Apply to Join']
562
- elsif owner.membership.statuses.present?
562
+ elsif owner.membership.statuses.any?(&:reinstatable?)
563
563
  ['Apply for Reinstatement', 'Apply to Join']
564
564
  else
565
565
  ['Apply to Reclassify']
@@ -151,7 +151,7 @@ module EffectiveMembershipsRegistrar
151
151
  save!(owner, date: date)
152
152
  end
153
153
 
154
- def reclassify!(owner, to:, date: nil, skip_fees: false)
154
+ def reclassify!(owner, to:, status: nil, date: nil, skip_fees: false)
155
155
  raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
156
156
  raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
157
157
 
@@ -159,6 +159,7 @@ module EffectiveMembershipsRegistrar
159
159
 
160
160
  raise('expecting a to memberships category') unless to.class.respond_to?(:effective_memberships_category?)
161
161
  raise('expecting a from memberships category') unless from.class.respond_to?(:effective_memberships_category?)
162
+ raise('expecting a memberships status') unless status.nil? || status.class.respond_to?(:effective_memberships_status?)
162
163
  raise('expected to and from to be different') if from == to
163
164
 
164
165
  date ||= Time.zone.now
@@ -171,6 +172,9 @@ module EffectiveMembershipsRegistrar
171
172
  membership.build_membership_category(category: to)
172
173
  membership.membership_category(category: from).mark_for_destruction
173
174
 
175
+ # Assign Status
176
+ membership.build_membership_status(status: status) if status.present?
177
+
174
178
  unless skip_fees
175
179
  fee = owner.build_prorated_fee(date: date)
176
180
  raise('already has purchased prorated fee') if fee.purchased?
@@ -202,32 +206,58 @@ module EffectiveMembershipsRegistrar
202
206
  save!(owner, date: date)
203
207
  end
204
208
 
205
- # This clears the status entirely from user
206
- def status_remove!(owner, date: nil)
207
- status_change!(owner, to: nil, date: date)
209
+ def status_clear!(owner, date: nil)
210
+ raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
211
+ raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
212
+
213
+ status_assign!(owner, date: date, status: [])
208
214
  end
209
215
 
210
- # To can be nil to clear the status entirely
211
- def status_change!(owner, to:, date: nil)
216
+ def status_add!(owner, status:, date: nil)
212
217
  raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
213
218
  raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
214
219
 
215
- from = owner.membership.status
220
+ status_assign!(owner, date: date, status: owner.membership.statuses + Array(status))
221
+ end
216
222
 
217
- raise('expecting a to memberships status') if to.present? && !to.class.respond_to?(:effective_memberships_status?)
218
- raise('expecting a from memberships status') if from.present? && !from.class.respond_to?(:effective_memberships_status?)
219
- raise('expected to and from to be different') if from == to
223
+ def status_remove!(owner, status:, date: nil)
224
+ raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
225
+ raise('owner must have an existing membership. use register! instead') if owner.membership.blank?
220
226
 
221
- date ||= Time.zone.now
227
+ status_assign!(owner, date: date, status: owner.membership.statuses - Array(status))
228
+ end
229
+
230
+ def status_assign!(owner, status:, date: nil)
231
+ raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
222
232
 
223
233
  membership = owner.membership
234
+ raise('owner must have an existing membership. use register! instead') if membership.blank?
224
235
 
225
- # Assign Status
226
- membership.build_membership_status(status: to) if to.present?
227
- membership.membership_status(status: from).mark_for_destruction if from.present?
236
+ statuses = Array(status)
237
+ raise('expected a memberships status') unless statuses.blank? || statuses.all? { |status| status.class.respond_to?(:effective_memberships_status?) }
228
238
 
229
- # Save
230
- save!(owner, date: date)
239
+ # Add
240
+ statuses.each do |status|
241
+ next if membership.membership_status(status: status).present?
242
+ membership.build_membership_status(status: status)
243
+ end
244
+
245
+ # Remove
246
+ membership.statuses.each do |existing|
247
+ next if statuses.include?(existing)
248
+ membership.membership_status(status: existing).mark_for_destruction
249
+ end
250
+
251
+ changed = membership.membership_statuses.any? { |ms| ms.new_record? || ms.marked_for_destruction? }
252
+
253
+ if changed
254
+ date ||= Time.zone.now
255
+
256
+ membership.registration_on = date # Always new registration_on
257
+ save!(owner, date: date)
258
+ end
259
+
260
+ true
231
261
  end
232
262
 
233
263
  def remove!(owner, date: nil)
@@ -68,4 +68,9 @@ module EffectiveMembershipsStatus
68
68
  status_type == 'Organization'
69
69
  end
70
70
 
71
+ # Used for Apply to Join Reinstatement
72
+ def reinstatable?
73
+ true
74
+ end
75
+
71
76
  end
@@ -3,7 +3,10 @@
3
3
 
4
4
  = card do
5
5
  - if resource.min_applicant_equivalences > 0
6
- .alert.alert-danger You must include #{resource.min_applicant_equivalences} or more equivalent memberships.
6
+ %p You must include #{resource.min_applicant_equivalences} or more equivalent memberships.
7
+
8
+ - if resource.min_applicant_equivalences == 0
9
+ %p Equivalent memberships are not required. Click the Remove button to skip adding memberships.
7
10
 
8
11
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
9
12
  = f.hidden_field :id
@@ -8,6 +8,9 @@
8
8
  - if resource.min_applicant_experiences_months > 0
9
9
  %p You must include #{resource.min_applicant_experiences_months} or more months of experience.
10
10
 
11
+ - if resource.min_applicant_educations == 0 && resource.min_applicant_experiences_months == 0
12
+ %p Work experience is not required. Click the Remove button to skip adding work experience.
13
+
11
14
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
12
15
  = f.hidden_field :id
13
16
  = f.error :applicant_experiences
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.6.3'
2
+ VERSION = '0.6.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.6.3
4
+ version: 0.6.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: 2022-08-31 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails