effective_memberships 0.1.2

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.
Files changed (152) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +114 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/effective_memberships_manifest.js +3 -0
  6. data/app/assets/javascripts/effective_memberships/applicant_courses.js +29 -0
  7. data/app/assets/javascripts/effective_memberships/applicant_experiences.js +38 -0
  8. data/app/assets/javascripts/effective_memberships/base.js +0 -0
  9. data/app/assets/javascripts/effective_memberships.js +1 -0
  10. data/app/assets/stylesheets/effective_memberships/base.scss +5 -0
  11. data/app/assets/stylesheets/effective_memberships.scss +1 -0
  12. data/app/controllers/admin/applicant_course_areas_controller.rb +15 -0
  13. data/app/controllers/admin/applicant_course_names_controller.rb +15 -0
  14. data/app/controllers/admin/applicants_controller.rb +33 -0
  15. data/app/controllers/admin/categories_controller.rb +19 -0
  16. data/app/controllers/admin/fees_controller.rb +18 -0
  17. data/app/controllers/admin/registrar_actions_controller.rb +49 -0
  18. data/app/controllers/effective/applicant_references_controller.rb +37 -0
  19. data/app/controllers/effective/applicants_controller.rb +34 -0
  20. data/app/controllers/effective/fee_payments_controller.rb +29 -0
  21. data/app/datatables/admin/effective_applicant_course_areas_datatable.rb +17 -0
  22. data/app/datatables/admin/effective_applicant_course_names_datatable.rb +17 -0
  23. data/app/datatables/admin/effective_applicants_datatable.rb +55 -0
  24. data/app/datatables/admin/effective_categories_datatable.rb +23 -0
  25. data/app/datatables/admin/effective_fees_datatable.rb +69 -0
  26. data/app/datatables/admin/effective_membership_histories_datatable.rb +35 -0
  27. data/app/datatables/effective_applicant_courses_datatable.rb +30 -0
  28. data/app/datatables/effective_applicant_educations_datatable.rb +22 -0
  29. data/app/datatables/effective_applicant_experiences_datatable.rb +42 -0
  30. data/app/datatables/effective_applicant_references_datatable.rb +34 -0
  31. data/app/datatables/effective_applicants_datatable.rb +34 -0
  32. data/app/helpers/effective_memberships_helper.rb +15 -0
  33. data/app/mailers/effective/memberships_mailer.rb +84 -0
  34. data/app/models/concerns/effective_memberships_applicant.rb +612 -0
  35. data/app/models/concerns/effective_memberships_applicant_review.rb +149 -0
  36. data/app/models/concerns/effective_memberships_category.rb +196 -0
  37. data/app/models/concerns/effective_memberships_fee_payment.rb +229 -0
  38. data/app/models/concerns/effective_memberships_owner.rb +263 -0
  39. data/app/models/concerns/effective_memberships_registrar.rb +300 -0
  40. data/app/models/effective/applicant.rb +7 -0
  41. data/app/models/effective/applicant_course.rb +40 -0
  42. data/app/models/effective/applicant_course_area.rb +31 -0
  43. data/app/models/effective/applicant_course_name.rb +29 -0
  44. data/app/models/effective/applicant_education.rb +36 -0
  45. data/app/models/effective/applicant_experience.rb +79 -0
  46. data/app/models/effective/applicant_reference.rb +81 -0
  47. data/app/models/effective/applicant_review.rb +7 -0
  48. data/app/models/effective/category.rb +7 -0
  49. data/app/models/effective/fee.rb +142 -0
  50. data/app/models/effective/fee_payment.rb +7 -0
  51. data/app/models/effective/membership.rb +119 -0
  52. data/app/models/effective/membership_category.rb +11 -0
  53. data/app/models/effective/membership_history.rb +40 -0
  54. data/app/models/effective/registrar.rb +19 -0
  55. data/app/models/effective/registrar_action.rb +97 -0
  56. data/app/views/admin/applicant_course_areas/_form.html.haml +8 -0
  57. data/app/views/admin/applicant_course_areas/_form_applicant_course_area.html.haml +8 -0
  58. data/app/views/admin/applicant_course_areas/index.html.haml +8 -0
  59. data/app/views/admin/applicant_course_name/_form.html.haml +9 -0
  60. data/app/views/admin/applicants/_form.html.haml +38 -0
  61. data/app/views/admin/applicants/_form_approve.html.haml +34 -0
  62. data/app/views/admin/applicants/_form_decline.html.haml +11 -0
  63. data/app/views/admin/applicants/_form_process.html.haml +18 -0
  64. data/app/views/admin/applicants/_status.html.haml +133 -0
  65. data/app/views/admin/categories/_form.html.haml +14 -0
  66. data/app/views/admin/categories/_form_applicant.html.haml +12 -0
  67. data/app/views/admin/categories/_form_applicant_content.html.haml +19 -0
  68. data/app/views/admin/categories/_form_applicant_eligibility.html.haml +13 -0
  69. data/app/views/admin/categories/_form_applicant_fees.html.haml +29 -0
  70. data/app/views/admin/categories/_form_applicant_steps.html.haml +42 -0
  71. data/app/views/admin/categories/_form_category.html.haml +10 -0
  72. data/app/views/admin/categories/_form_fee_payment.html.haml +9 -0
  73. data/app/views/admin/categories/_form_fee_payment_content.html.haml +19 -0
  74. data/app/views/admin/categories/_form_fee_payment_steps.html.haml +9 -0
  75. data/app/views/admin/categories/_form_renewals.html.haml +32 -0
  76. data/app/views/admin/fees/_fee.html.haml +1 -0
  77. data/app/views/admin/fees/_form.html.haml +14 -0
  78. data/app/views/admin/memberships/_status.html.haml +6 -0
  79. data/app/views/admin/registrar_actions/_form.html.haml +10 -0
  80. data/app/views/admin/registrar_actions/_form_bad_standing.html.haml +43 -0
  81. data/app/views/admin/registrar_actions/_form_fees_paid.html.haml +30 -0
  82. data/app/views/admin/registrar_actions/_form_reclassify.html.haml +43 -0
  83. data/app/views/admin/registrar_actions/_form_register.html.haml +44 -0
  84. data/app/views/admin/registrar_actions/_form_remove.html.haml +17 -0
  85. data/app/views/effective/applicant_references/_applicant_reference.html.haml +51 -0
  86. data/app/views/effective/applicant_references/_datatable_actions.html.haml +4 -0
  87. data/app/views/effective/applicant_references/_form.html.haml +18 -0
  88. data/app/views/effective/applicant_references/_form_declaration.html.haml +37 -0
  89. data/app/views/effective/applicant_references/complete.html.haml +3 -0
  90. data/app/views/effective/applicant_references/edit.html.haml +8 -0
  91. data/app/views/effective/applicants/_applicant.html.haml +6 -0
  92. data/app/views/effective/applicants/_content.html.haml +10 -0
  93. data/app/views/effective/applicants/_course_amounts.html.haml +19 -0
  94. data/app/views/effective/applicants/_dashboard.html.haml +19 -0
  95. data/app/views/effective/applicants/_declarations.html.haml +16 -0
  96. data/app/views/effective/applicants/_demographics.html.haml +9 -0
  97. data/app/views/effective/applicants/_demographics_fields.html.haml +11 -0
  98. data/app/views/effective/applicants/_demographics_owner.html.haml +20 -0
  99. data/app/views/effective/applicants/_education.html.haml +14 -0
  100. data/app/views/effective/applicants/_experience.html.haml +28 -0
  101. data/app/views/effective/applicants/_files.html.haml +27 -0
  102. data/app/views/effective/applicants/_layout.html.haml +3 -0
  103. data/app/views/effective/applicants/_orders.html.haml +4 -0
  104. data/app/views/effective/applicants/_references.html.haml +15 -0
  105. data/app/views/effective/applicants/_summary.html.haml +40 -0
  106. data/app/views/effective/applicants/billing.html.haml +14 -0
  107. data/app/views/effective/applicants/checkout.html.haml +6 -0
  108. data/app/views/effective/applicants/course_amounts.html.haml +50 -0
  109. data/app/views/effective/applicants/declarations.html.haml +19 -0
  110. data/app/views/effective/applicants/demographics.html.haml +11 -0
  111. data/app/views/effective/applicants/education.html.haml +27 -0
  112. data/app/views/effective/applicants/experience.html.haml +51 -0
  113. data/app/views/effective/applicants/files.html.haml +14 -0
  114. data/app/views/effective/applicants/references.html.haml +24 -0
  115. data/app/views/effective/applicants/select.html.haml +27 -0
  116. data/app/views/effective/applicants/start.html.haml +18 -0
  117. data/app/views/effective/applicants/submitted.html.haml +44 -0
  118. data/app/views/effective/applicants/summary.html.haml +8 -0
  119. data/app/views/effective/fee_payments/_content.html.haml +8 -0
  120. data/app/views/effective/fee_payments/_declarations.html.haml +16 -0
  121. data/app/views/effective/fee_payments/_demographics.html.haml +9 -0
  122. data/app/views/effective/fee_payments/_demographics_fields.html.haml +11 -0
  123. data/app/views/effective/fee_payments/_demographics_owner.html.haml +20 -0
  124. data/app/views/effective/fee_payments/_fee_payment.html.haml +6 -0
  125. data/app/views/effective/fee_payments/_layout.html.haml +3 -0
  126. data/app/views/effective/fee_payments/_orders.html.haml +4 -0
  127. data/app/views/effective/fee_payments/billing.html.haml +14 -0
  128. data/app/views/effective/fee_payments/checkout.html.haml +6 -0
  129. data/app/views/effective/fee_payments/declarations.html.haml +20 -0
  130. data/app/views/effective/fee_payments/demographics.html.haml +12 -0
  131. data/app/views/effective/fee_payments/start.html.haml +20 -0
  132. data/app/views/effective/fee_payments/submitted.html.haml +14 -0
  133. data/app/views/effective/fee_payments/summary.html.haml +8 -0
  134. data/app/views/effective/fees/_dashboard.html.haml +22 -0
  135. data/app/views/effective/fees/_fee.html.haml +37 -0
  136. data/app/views/effective/memberships/_dashboard.html.haml +29 -0
  137. data/app/views/effective/memberships/_membership.html.haml +40 -0
  138. data/app/views/effective/memberships_mailer/applicant_approved.liquid +15 -0
  139. data/app/views/effective/memberships_mailer/applicant_declined.liquid +13 -0
  140. data/app/views/effective/memberships_mailer/applicant_reference_notification.liquid +15 -0
  141. data/app/views/layouts/effective_memberships_mailer_layout.html.haml +7 -0
  142. data/config/effective_memberships.rb +47 -0
  143. data/config/routes.rb +32 -0
  144. data/db/migrate/01_create_effective_memberships.rb.erb +380 -0
  145. data/db/seeds.rb +59 -0
  146. data/lib/effective_memberships/engine.rb +23 -0
  147. data/lib/effective_memberships/version.rb +3 -0
  148. data/lib/effective_memberships.rb +86 -0
  149. data/lib/generators/effective_memberships/install_generator.rb +40 -0
  150. data/lib/generators/templates/effective_memberships_mailer_preview.rb +4 -0
  151. data/lib/tasks/effective_memberships_tasks.rake +17 -0
  152. metadata +377 -0
@@ -0,0 +1,69 @@
1
+ module Admin
2
+ class EffectiveFeesDatatable < Effective::Datatable
3
+ filters do
4
+ scope :all
5
+ scope :purchased
6
+ scope :not_purchased
7
+ end
8
+
9
+ datatable do
10
+ order :id, :desc
11
+
12
+ col :updated_at, visible: false
13
+ col :created_at, visible: false
14
+ col :id, visible: false
15
+
16
+ unless attributes[:owner_id] || attributes[:applicant_id] || attributes[:fee_payment_id]
17
+ col :owner
18
+ end
19
+
20
+ unless attributes[:applicant_id] || attributes[:fee_payment_id]
21
+ col :parent, search: :string, visible: false
22
+ end
23
+
24
+ col :fee_type, search: EffectiveMemberships.fee_types
25
+ col :price, as: :price
26
+ col :purchased?, as: :boolean
27
+ col :purchased_order, visible: false
28
+
29
+ col :category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
30
+
31
+ aggregate :total
32
+
33
+ if attributes[:applicant_id]
34
+ actions_col(new: false)
35
+ else
36
+ actions_col
37
+ end
38
+ end
39
+
40
+ collection do
41
+ scope = Effective::Fee.deep.all
42
+
43
+ raise('expected an owner_id, not user_id') if attributes[:user_id].present?
44
+
45
+ if attributes[:owner_id]
46
+ scope = scope.where(owner_id: attributes[:owner_id])
47
+ end
48
+
49
+ if attributes[:applicant_id]
50
+ scope = scope.where(parent: applicant)
51
+ end
52
+
53
+ if attributes[:fee_payment_id]
54
+ scope = scope.where(parent: fee_payment)
55
+ end
56
+
57
+ scope
58
+ end
59
+
60
+ def applicant
61
+ @applicant ||= EffectiveMemberships.Applicant.find(attributes[:applicant_id])
62
+ end
63
+
64
+ def fee_payment
65
+ @fee_payment ||= EffectiveMemberships.FeePayment.find(attributes[:fee_payment_id])
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,35 @@
1
+ module Admin
2
+ class EffectiveMembershipHistoriesDatatable < Effective::Datatable
3
+ datatable do
4
+ order :id, :desc
5
+
6
+ col :updated_at, visible: false
7
+ col :created_at, visible: false
8
+ col :id, visible: false
9
+
10
+ col :start_on
11
+ col :end_on
12
+
13
+ col :owner
14
+
15
+ col :number
16
+
17
+ col :categories, label: 'Category'
18
+ col :category_ids, visible: false
19
+
20
+ col :bad_standing
21
+ col :removed
22
+
23
+ actions_col
24
+ end
25
+
26
+ collection do
27
+ raise('expected an owner_id, not user_id') if attributes[:user_id].present?
28
+
29
+ scope = Effective::MembershipHistory.deep.all
30
+ scope = scope.where(owner_id: attributes[:owner_id]) if attributes[:owner_id]
31
+ scope
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ class EffectiveApplicantCoursesDatatable < Effective::Datatable
2
+ datatable do
3
+ length :all
4
+
5
+ col :applicant_course_area
6
+
7
+ if applicant.has_completed_step?(:course_amounts)
8
+ col :applicant_course_name, label: 'Course'
9
+ col :amount
10
+ end
11
+
12
+ if applicant.has_completed_step?(:courses)
13
+ col :title, visible: false, label: 'Course'
14
+ col :code, visible: false
15
+ col :description, visible: false
16
+ end
17
+
18
+ end
19
+
20
+ collection do
21
+ Effective::ApplicantCourse.deep.where(applicant: applicant)
22
+ .joins(:applicant_course_area)
23
+ .joins(:applicant_course_name)
24
+ .order('applicant_course_areas.position, applicant_course_names.position, applicant_courses.title')
25
+ end
26
+
27
+ def applicant
28
+ @applicant ||= EffectiveMemberships.Applicant.where(id: attributes[:applicant_id]).first!
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ class EffectiveApplicantEducationsDatatable < Effective::Datatable
2
+ datatable do
3
+ length :all
4
+ order :start_on
5
+
6
+ col :start_on
7
+ col :end_on
8
+
9
+ col :institution
10
+ col :location
11
+
12
+ col :degree_obtained
13
+ end
14
+
15
+ collection do
16
+ Effective::ApplicantEducation.deep.where(applicant: applicant)
17
+ end
18
+
19
+ def applicant
20
+ @applicant ||= EffectiveMemberships.Applicant.where(id: attributes[:applicant_id]).first!
21
+ end
22
+ end
@@ -0,0 +1,42 @@
1
+ class EffectiveApplicantExperiencesDatatable < Effective::Datatable
2
+ datatable do
3
+ length :all
4
+ order :start_on
5
+
6
+ col :start_on
7
+
8
+ col :end_on do |applicant_experience|
9
+ if applicant_experience.still_work_here?
10
+ 'Still there'
11
+ else
12
+ applicant_experience.end_on&.strftime('%F')
13
+ end
14
+ end
15
+
16
+ col :position
17
+ col :employer
18
+
19
+ col :still_work_here, visible: false
20
+
21
+ col :level, label: 'Employment' do |applicant_experience|
22
+ if applicant_experience.part_time?
23
+ applicant_experience.level + ' ' + applicant_experience.percent_worked_to_s
24
+ else
25
+ applicant_experience.level
26
+ end
27
+ end
28
+
29
+ col :percent_worked, as: :percent, visible: false
30
+
31
+ col :months
32
+ col :tasks_performed
33
+ end
34
+
35
+ collection do
36
+ Effective::ApplicantExperience.deep.where(applicant: applicant)
37
+ end
38
+
39
+ def applicant
40
+ @applicant ||= EffectiveMemberships.Applicant.where(id: attributes[:applicant_id]).first!
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ # For the applicant complete step to add additional applicants
2
+ class EffectiveApplicantReferencesDatatable < Effective::Datatable
3
+
4
+ datatable do
5
+ order :name
6
+
7
+ col :name
8
+ col :email
9
+ col :phone
10
+
11
+ col :status do |reference|
12
+ if reference.submitted?
13
+ 'Waiting on response'
14
+ elsif reference.completed?
15
+ 'Completed'
16
+ end
17
+ end
18
+
19
+ col :last_notified_at do |reference|
20
+ reference.last_notified_at&.strftime('%F') unless reference.completed?
21
+ end
22
+
23
+ actions_col partial: 'effective/applicant_references/datatable_actions', partial_as: :applicant_reference
24
+ end
25
+
26
+ collection do
27
+ Effective::ApplicantReference.deep.where(applicant: applicant)
28
+ end
29
+
30
+ def applicant
31
+ @applicant ||= EffectiveMemberships.Applicant.where(id: attributes[:applicant_id]).first!
32
+ end
33
+
34
+ end
@@ -0,0 +1,34 @@
1
+ # Dashboard Applicants
2
+ class EffectiveApplicantsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :created_at
5
+
6
+ col :id, visible: false
7
+
8
+ col :category, label: 'Category'
9
+ col :status
10
+
11
+ col :created_at, label: 'Created', as: :date
12
+ col :updated_at, label: 'Updated', as: :date, visible: false
13
+ col :submitted_at, label: 'Submitted', as: :date
14
+ col :completed_at, label: 'Completed', as: :date
15
+ col :reviewed_at, label: 'Reviewed', as: :date
16
+ col :approved_at, label: 'Approved', visible: false, as: :date
17
+
18
+ col :orders
19
+
20
+ actions_col(show: false) do |applicant|
21
+ if applicant.draft?
22
+ dropdown_link_to('Continue', effective_memberships.applicant_build_path(applicant, applicant.next_step), 'data-turbolinks' => false)
23
+ dropdown_link_to('Delete', effective_memberships.applicant_path(applicant), 'data-confirm': "Really delete #{applicant}?", 'data-method': :delete)
24
+ else
25
+ dropdown_link_to('Show', effective_memberships.applicant_path(applicant))
26
+ end
27
+ end
28
+ end
29
+
30
+ collection do
31
+ EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owner)
32
+ end
33
+
34
+ end
@@ -0,0 +1,15 @@
1
+ module EffectiveMembershipsHelper
2
+
3
+ def edit_effective_applicants_wizard?
4
+ params[:controller] == 'effective/applicants' && defined?(resource) && resource.draft?
5
+ end
6
+
7
+ def edit_effective_applicant_reviews_wizard?
8
+ params[:controller] == 'effective/applicant_reviews' && defined?(resource) && resource.draft?
9
+ end
10
+
11
+ def edit_effective_fee_payments_wizard?
12
+ params[:controller] == 'effective/fee_payments' && defined?(resource) && resource.draft?
13
+ end
14
+
15
+ end
@@ -0,0 +1,84 @@
1
+ module Effective
2
+ class MembershipsMailer < EffectiveMemberships.parent_mailer_class
3
+ include EffectiveEmailTemplatesMailer
4
+
5
+ default from: -> { EffectiveMemberships.mailer_sender }
6
+ layout -> { EffectiveMemberships.mailer_layout || 'effective_memberships_mailer_layout' }
7
+
8
+ def applicant_approved(resource, opts = {})
9
+ @assigns = assigns_for(resource)
10
+ mail(to: EffectiveMemberships.mailer_admin, **headers_for(resource, opts))
11
+ end
12
+
13
+ def applicant_declined(resource, opts = {})
14
+ @assigns = assigns_for(resource)
15
+ mail(to: EffectiveMemberships.mailer_admin, **headers_for(resource, opts))
16
+ end
17
+
18
+ def applicant_reference_notification(resource, opts = {})
19
+ @assigns = assigns_for(resource)
20
+ mail(to: resource.email, **headers_for(resource, opts))
21
+ end
22
+
23
+ protected
24
+
25
+ def headers_for(resource, opts = {})
26
+ resource.respond_to?(:log_changes_datatable) ? opts.merge(log: resource) : opts
27
+ end
28
+
29
+ def assigns_for(resource)
30
+ if resource.class.respond_to?(:effective_memberships_applicant?)
31
+ return applicant_assigns(resource).merge(user_assigns(resource.owner))
32
+ end
33
+
34
+ if resource.kind_of?(Effective::ApplicantReference)
35
+ return reference_assigns(resource).merge(user_assigns(resource.applicant.owner))
36
+ end
37
+
38
+ raise('unexpected resource')
39
+ end
40
+
41
+ def applicant_assigns(applicant)
42
+ raise('expected an applicant') unless applicant.class.respond_to?(:effective_memberships_applicant?)
43
+
44
+ values = {
45
+ date: (applicant.submitted_at || Time.zone.now).strftime('%F'),
46
+
47
+ to_category: applicant.category.to_s,
48
+ from_category: applicant.from_category.to_s,
49
+
50
+ url: effective_memberships.applicant_url(applicant),
51
+ admin_url: effective_memberships.edit_admin_applicant_url(applicant),
52
+ }
53
+
54
+ if applicant.declined_reason.present?
55
+ values.merge!(declined_reason: applicant.declined_reason)
56
+ end
57
+
58
+ { applicant: values }
59
+ end
60
+
61
+ def reference_assigns(applicant_reference)
62
+ raise('expected a reference') unless applicant_reference.kind_of?(Effective::ApplicantReference)
63
+
64
+ values = {
65
+ name: applicant_reference.name,
66
+ url: effective_memberships.applicant_reference_url(applicant_reference)
67
+ }
68
+
69
+ { reference: values }
70
+ end
71
+
72
+ def user_assigns(owner)
73
+ raise('expected a owner') unless owner.class.respond_to?(:effective_memberships_owner?)
74
+
75
+ values = {
76
+ name: owner.to_s,
77
+ email: owner.email
78
+ }
79
+
80
+ { user: values }
81
+ end
82
+
83
+ end
84
+ end