effective_memberships 0.2.5 → 0.3.2

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: 5349de013b96f392cd5d9965a55fc8348656aed3a20b9c2798538454286368cd
4
- data.tar.gz: 1f04f3dfd643b060a48919a00705255590439632fa4afd03925c0b1abe6ab324
3
+ metadata.gz: 0bc312d4be0f593086ccda4c567644f539f733dc019e1580f7b79c82a20343d1
4
+ data.tar.gz: 5607e8a5cc0223e5e5c80856b2ee7227d8da9d5799e34da85d3d6c5f6fb22018
5
5
  SHA512:
6
- metadata.gz: 1a9056129fa56370cf1dd1b9324b1f2581f81b3952f801f3509e60d68de68da6c65c7cf3a898bfd525d9e4a5ad3b648088e2e5218ead9448288bd67a9daf783e
7
- data.tar.gz: 0f75e5e23b53188eb83524190ad4fc7292bddb7af3faf349207074a3bc0b4da660ea41415392933c851843d1c57b1eafa43127fd3c6f9ac2dfeca5f43fe5f303
6
+ metadata.gz: c8fd4647fa682ceaf5db08536bc1f709f21a4312d42e979500850350f79ee235dd83e4d490417521b7e456f910ad418d0ae70988fd09197dd2e8b240393e612d
7
+ data.tar.gz: 5c864a7bc2a30b7a7cc0d63faddc185a914f295a61b67f58f92899ad1328278d3f9ddbecb115e4517e9b2f292322c9c8010db3b89992ecd6bb9d81cb8cf339c5
@@ -77,26 +77,26 @@ module EffectiveMembershipsApplicant
77
77
  belongs_to :category, polymorphic: true, optional: true
78
78
  belongs_to :from_category, polymorphic: true, optional: true
79
79
 
80
- has_many :applicant_reviews, -> { order(:id) }, inverse_of: :applicant, dependent: :destroy
80
+ has_many :applicant_reviews, -> { order(:id) }, as: :applicant, inverse_of: :applicant, dependent: :destroy
81
81
  accepts_nested_attributes_for :applicant_reviews, reject_if: :all_blank, allow_destroy: true
82
82
 
83
83
  # Effective Namespace
84
- has_many :applicant_courses, -> { order(:id) }, class_name: 'Effective::ApplicantCourse', inverse_of: :applicant, dependent: :destroy
84
+ has_many :applicant_courses, -> { order(:id) }, class_name: 'Effective::ApplicantCourse', as: :applicant, inverse_of: :applicant, dependent: :destroy
85
85
  accepts_nested_attributes_for :applicant_courses, reject_if: :all_blank, allow_destroy: true
86
86
 
87
- has_many :applicant_educations, -> { order(:id) }, class_name: 'Effective::ApplicantEducation', inverse_of: :applicant, dependent: :destroy
87
+ has_many :applicant_educations, -> { order(:id) }, class_name: 'Effective::ApplicantEducation', as: :applicant, inverse_of: :applicant, dependent: :destroy
88
88
  accepts_nested_attributes_for :applicant_educations, reject_if: :all_blank, allow_destroy: true
89
89
 
90
- has_many :applicant_experiences, -> { order(:id) }, class_name: 'Effective::ApplicantExperience', inverse_of: :applicant, dependent: :destroy
90
+ has_many :applicant_experiences, -> { order(:id) }, class_name: 'Effective::ApplicantExperience', as: :applicant, inverse_of: :applicant, dependent: :destroy
91
91
  accepts_nested_attributes_for :applicant_experiences, reject_if: :all_blank, allow_destroy: true
92
92
 
93
- has_many :applicant_references, -> { order(:id) }, class_name: 'Effective::ApplicantReference', inverse_of: :applicant, dependent: :destroy
93
+ has_many :applicant_references, -> { order(:id) }, class_name: 'Effective::ApplicantReference', as: :applicant, inverse_of: :applicant, dependent: :destroy
94
94
  accepts_nested_attributes_for :applicant_references, reject_if: :all_blank, allow_destroy: true
95
95
 
96
- has_many :fees, -> { order(:id) }, as: :parent, class_name: 'Effective::Fee', dependent: :nullify
96
+ has_many :fees, -> { order(:id) }, as: :parent, inverse_of: :parent, class_name: 'Effective::Fee', dependent: :nullify
97
97
  accepts_nested_attributes_for :fees, reject_if: :all_blank, allow_destroy: true
98
98
 
99
- has_many :orders, -> { order(:id) }, as: :parent, class_name: 'Effective::Order', dependent: :nullify
99
+ has_many :orders, -> { order(:id) }, as: :parent, inverse_of: :parent, class_name: 'Effective::Order', dependent: :nullify
100
100
  accepts_nested_attributes_for :orders
101
101
 
102
102
  effective_resource do
@@ -312,13 +312,15 @@ module EffectiveMembershipsApplicant
312
312
  raise('already submitted') if was_submitted?
313
313
  raise('expected a purchased order') unless submit_order&.purchased?
314
314
 
315
+ wizard_steps[:checkout] ||= Time.zone.now
316
+ wizard_steps[:submitted] = Time.zone.now
317
+ submitted!
318
+
315
319
  after_commit do
316
320
  applicant_references.each { |reference| reference.notify! if reference.submitted? }
317
321
  end
318
322
 
319
- wizard_steps[:checkout] ||= Time.zone.now
320
- wizard_steps[:submitted] = Time.zone.now
321
- submitted!
323
+ true
322
324
  end
323
325
 
324
326
  end
@@ -526,9 +528,10 @@ module EffectiveMembershipsApplicant
526
528
  raise('unsupported approval applicant_type')
527
529
  end
528
530
 
529
- after_commit { send_email(:applicant_approved) }
530
-
531
531
  save!
532
+
533
+ after_commit { send_email(:applicant_approved) }
534
+ true
532
535
  end
533
536
 
534
537
  # Admin approves an applicant. Registers the owner. Sends an email.
@@ -542,9 +545,10 @@ module EffectiveMembershipsApplicant
542
545
  wizard_steps[:submitted] ||= Time.zone.now
543
546
  declined!
544
547
 
545
- after_commit { send_email(:applicant_declined) }
546
-
547
548
  save!
549
+
550
+ after_commit { send_email(:applicant_declined) }
551
+ true
548
552
  end
549
553
 
550
554
  private
@@ -109,30 +109,33 @@ module EffectiveMembershipsApplicantReview
109
109
  end
110
110
 
111
111
  def conflict_of_interest!
112
- after_commit { send_email(:applicant_review_conflict_of_interest) }
113
-
114
112
  update!(conflict_of_interest: true, recommendation: nil)
115
113
  conflicted!
116
114
 
117
115
  applicant.save!
116
+
117
+ after_commit { send_email(:applicant_review_conflict_of_interest) }
118
+ true
118
119
  end
119
120
 
120
121
  def accept!
121
- after_commit { send_email(:applicant_review_completed) }
122
-
123
122
  assign_attributes(recommendation: 'Accept')
124
123
  accepted!
125
124
 
126
125
  applicant.save!
127
- end
128
126
 
129
- def reject!
130
127
  after_commit { send_email(:applicant_review_completed) }
128
+ true
129
+ end
131
130
 
131
+ def reject!
132
132
  assign_attributes(recommendation: 'Reject')
133
133
  rejected!
134
134
 
135
135
  applicant.save!
136
+
137
+ after_commit { send_email(:applicant_review_completed) }
138
+ true
136
139
  end
137
140
 
138
141
  private
@@ -4,8 +4,8 @@ module Effective
4
4
 
5
5
  belongs_to :applicant_course_area
6
6
 
7
+ belongs_to :applicant, polymorphic: true, optional: true
7
8
  belongs_to :applicant_course_name, optional: true
8
- belongs_to :applicant, optional: true
9
9
 
10
10
  effective_resource do
11
11
  title :string
@@ -17,7 +17,7 @@ module Effective
17
17
  timestamps
18
18
  end
19
19
 
20
- scope :deep, -> { includes(:applicant_course_area, :applicant_course_name, :applicant) }
20
+ scope :deep, -> { includes(:applicant_course_area, :applicant_course_name) }
21
21
  scope :sorted, -> { order(:title) }
22
22
 
23
23
  before_validation(if: -> { applicant_course_name.present? }) do
@@ -1,6 +1,6 @@
1
1
  module Effective
2
2
  class ApplicantEducation < ActiveRecord::Base
3
- belongs_to :applicant
3
+ belongs_to :applicant, polymorphic: true
4
4
 
5
5
  log_changes(to: :applicant) if respond_to?(:log_changes)
6
6
 
@@ -16,7 +16,7 @@ module Effective
16
16
  timestamps
17
17
  end
18
18
 
19
- scope :deep, -> { includes(:applicant) }
19
+ scope :deep, -> { all }
20
20
 
21
21
  validates :start_on, presence: true
22
22
  validates :end_on, presence: true
@@ -1,6 +1,6 @@
1
1
  module Effective
2
2
  class ApplicantExperience < ActiveRecord::Base
3
- belongs_to :applicant
3
+ belongs_to :applicant, polymorphic: true
4
4
 
5
5
  log_changes(to: :applicant) if respond_to?(:log_changes)
6
6
 
@@ -25,7 +25,7 @@ module Effective
25
25
  timestamps
26
26
  end
27
27
 
28
- scope :deep, -> { includes(:applicant) }
28
+ scope :deep, -> { all }
29
29
 
30
30
  before_validation(if: -> { start_on.present? && end_on.present? }) do
31
31
  self.months ||= ((end_on - start_on) / 1.month).to_i
@@ -5,7 +5,7 @@ module Effective
5
5
  acts_as_statused :submitted, :completed
6
6
  log_changes(to: :applicant) if respond_to?(:log_changes)
7
7
 
8
- belongs_to :applicant
8
+ belongs_to :applicant, polymorphic: true
9
9
 
10
10
  KNOWNS = ['6 months - 1 year', '1 year - 2 years', '2 - 5 years', '5 - 10 years', 'More than 10 years']
11
11
  RELATIONSHIPS = ['Supervisor', 'Employer', 'Colleague', 'Other']
@@ -38,7 +38,7 @@ module Effective
38
38
  timestamps
39
39
  end
40
40
 
41
- scope :deep, -> { includes(:applicant) }
41
+ scope :deep, -> { all }
42
42
 
43
43
  # All step validations
44
44
  validates :applicant, presence: true
@@ -172,6 +172,7 @@ class CreateEffectiveMemberships < ActiveRecord::Migration[6.0]
172
172
  # Applicant Educations
173
173
  create_table :applicant_educations do |t|
174
174
  t.integer :applicant_id
175
+ t.string :applicant_type
175
176
 
176
177
  t.date :start_on
177
178
  t.date :end_on
@@ -191,6 +192,7 @@ class CreateEffectiveMemberships < ActiveRecord::Migration[6.0]
191
192
  # Applicant Experiences
192
193
  create_table :applicant_experiences do |t|
193
194
  t.integer :applicant_id
195
+ t.string :applicant_type
194
196
 
195
197
  t.string :level
196
198
  t.integer :months
@@ -216,6 +218,7 @@ class CreateEffectiveMemberships < ActiveRecord::Migration[6.0]
216
218
  # Applicant References
217
219
  create_table :applicant_references do |t|
218
220
  t.integer :applicant_id
221
+ t.string :applicant_type
219
222
 
220
223
  t.string :name
221
224
  t.string :email
@@ -264,7 +267,9 @@ class CreateEffectiveMemberships < ActiveRecord::Migration[6.0]
264
267
  create_table :applicant_courses do |t|
265
268
  t.integer :applicant_course_area_id
266
269
  t.integer :applicant_course_name_id
270
+
267
271
  t.integer :applicant_id
272
+ t.string :applicant_type
268
273
 
269
274
  t.string :title
270
275
  t.integer :amount
@@ -279,7 +284,9 @@ class CreateEffectiveMemberships < ActiveRecord::Migration[6.0]
279
284
  # Applicant Reviews
280
285
  create_table :applicant_reviews do |t|
281
286
  t.string :token
287
+
282
288
  t.integer :applicant_id
289
+ t.string :applicant_type
283
290
 
284
291
  t.integer :reviewer_id
285
292
  t.string :reviewer_type
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.2.5'
2
+ VERSION = '0.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_memberships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect